/* Word Push — full-height battlefield, controls on the map */
@font-face {
  font-family: "Nunito";
  src: url("../fonts/Nunito-Variable.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #2a3d28;
  --surface: #fffdf8;
  --text: #1c1915;
  --muted: #5c564c;
  --accent: #0f6e6b;
  --danger: #9f2d2d;
  --radius: 12px;
  --tap: 46px;
  --mode-tap: 42px;
  --gap: 6px;
  --font: "Nunito", system-ui, -apple-system, sans-serif;
  --overlay-h: 20%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

#app {
  position: relative;
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: 430px;
  margin-left: auto;
  margin-right: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.battle-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #4d7d42;
}

#battle {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud--overlay {
  position: absolute;
  top: 6px;
  left: 8px;
  right: 8px;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gap);
  pointer-events: none;
}

.hud__pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
}

.hud__stat {
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.hud__stat--muted {
  color: var(--danger);
  font-weight: 700;
}

.hud__dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.5;
}

.hud__tools {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.icon-btn {
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.icon-btn--glass {
  background: rgba(255, 253, 248, 0.9);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.icon-btn:active {
  transform: scale(0.96);
}

.enemy-letters {
  position: absolute;
  top: 48px;
  left: 8px;
  right: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.enemy-letters__label {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 253, 248, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.play-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 6px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: none;
}

.play-overlay > * {
  pointer-events: auto;
}

.solve-row,
.strip-row {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--gap);
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.solve-row::-webkit-scrollbar,
.strip-row::-webkit-scrollbar {
  display: none;
}

.solve-row:empty {
  display: none;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.strip-row--mini .letter-tile {
  width: 28px;
  height: 28px;
  font-size: 0.65rem;
  border-radius: 8px;
  border-width: 1px;
  opacity: 0.95;
}

.letter-tile {
  flex-shrink: 0;
  width: var(--tap);
  height: var(--tap);
  border: 2px solid rgba(255, 253, 248, 0.65);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.92);
  color: var(--text);
  font-weight: 800;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}

.letter-tile:active {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.letter-tile--vibrate {
  animation: letter-vibrate 0.35s ease-in-out infinite;
}

.letter-tile__char {
  line-height: 1;
}

.letter-tile__glyph {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 0.6rem;
  color: var(--accent);
}

.letter-tile__glyph--danger {
  color: var(--danger);
}

@keyframes letter-vibrate {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px) rotate(-2deg);
  }
  75% {
    transform: translateX(3px) rotate(2deg);
  }
}

.letter-tile--dragging {
  opacity: 0.9;
  z-index: 10;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.mode-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  width: 100%;
}

.btn {
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}

.btn--mode {
  flex: 1 1 0;
  min-width: 0;
  max-width: var(--mode-tap);
  height: var(--mode-tap);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  border: 2px solid rgba(255, 253, 248, 0.5);
  background: rgba(255, 253, 248, 0.78);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn--mode:active {
  transform: translateY(1px);
}

.btn--mode.btn--mode-on {
  color: #fff;
  border-color: #0a5855;
  background: linear-gradient(180deg, #15908c 0%, #0f6e6b 55%, #0a5855 100%);
  box-shadow: 0 3px 0 #084845;
}

.mode-tile.shop-gold {
  flex: 1 1 0;
  min-width: 0;
  max-width: var(--mode-tap);
  height: var(--mode-tap);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: #0a5855;
  border: 2px solid rgba(255, 253, 248, 0.55);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn--push {
  width: 100%;
  min-height: 50px;
  background: linear-gradient(180deg, #15908c 0%, #0f6e6b 55%, #0a5855 100%);
  color: #fff;
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: var(--radius);
  box-shadow: 0 4px 0 #084845, 0 6px 14px rgba(0, 0, 0, 0.28);
}

.btn--push:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #084845;
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn--primary {
  min-height: var(--tap);
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn--secondary {
  min-height: var(--tap);
  background: var(--surface);
  border: 2px solid rgba(28, 25, 21, 0.12);
  width: 100%;
}

dialog.game-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(340px, 92vw);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

dialog.game-dialog::backdrop {
  background: rgba(28, 25, 21, 0.6);
}

.dialog-inner {
  padding: 20px;
}

.dialog-inner h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.dialog-inner p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.4;
}

.dialog-actions {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.solve-snap {
  animation: solve-snap 0.32s ease;
}

@keyframes solve-snap {
  0% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(-6px);
  }
  60% {
    transform: translateX(5px);
  }
  100% {
    transform: translateX(0);
  }
}

@media (min-height: 740px) {
  :root {
    --overlay-h: 18%;
    --tap: 48px;
    --mode-tap: 44px;
  }
}
