*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

html, body {
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.screen {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 16px;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--border-radius);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-primary:disabled {
  background: #555;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--text-bright);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover {
  color: var(--text);
}

.btn-back {
  background: transparent;
  color: var(--text-dim);
  padding: 8px 12px;
  font-size: 18px;
}
.btn-back:hover {
  color: var(--text);
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-attack {
  background: var(--danger);
  color: white;
  font-size: 18px;
  padding: 14px 32px;
  margin: 0 auto;
  display: block;
}
.btn-attack:hover {
  background: #f05040;
}
.btn-attack:disabled {
  background: #555;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.top-bar h2 {
  flex: 1;
  font-size: 20px;
}

.exp-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0;
}
.exp-bar.large {
  height: 10px;
  border-radius: 5px;
}
.exp-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.5s ease;
}

.modal-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
}
.modal h3 {
  margin-bottom: 12px;
  font-size: 18px;
}
.modal h2 {
  margin-bottom: 8px;
  font-size: 24px;
  text-align: center;
}
.modal .btn {
  margin-top: 8px;
  width: 100%;
}
.modal label {
  display: block;
  margin-bottom: 12px;
  color: var(--text-dim);
  font-size: 14px;
}
.modal input[type="text"] {
  width: 100%;
  margin-top: 4px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  color: var(--text);
  font-size: 16px;
}
.modal input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: var(--text-dim);
  font-size: 14px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.divider span {
  padding: 0 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }