:root {
  --bg1: #FFEB3B;
  --bg2: #FDD835;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.85);
  --text: #211A16;
  --muted: #5C4030;
  --accent: #B7410E;
  --accent-2: #8D4925;
  --outline: #211A16;
  --cream: #F5E6BE;
  --success: #2F9E44;
  --danger: #B7410E;
  --tile-shadow: 0 5px 0 rgba(33, 26, 22, 0.22);
  --radius: 18px;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg1);
  touch-action: manipulation;
  user-select: none;
}

body {
  background: radial-gradient(circle at 50% 40%, var(--bg1) 0%, var(--bg2) 100%);
}

#app {
  position: relative;
  width: min(100vw, 480px);
  height: 100%;
  max-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 18px max(16px, env(safe-area-inset-bottom));
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  z-index: 2;
}

.screen[hidden] {
  display: none !important;
}

.overlay-screen {
  justify-content: center;
  background: rgba(59, 36, 20, 0.45);
  backdrop-filter: blur(6px);
  z-index: 5;
}

/* Sunburst like brand art */
.sunburst {
  position: absolute;
  inset: -40%;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-conic-gradient(
      from 0deg at 50% 45%,
      rgba(255, 255, 255, 0.28) 0deg 60deg,
      rgba(255, 200, 0, 0.08) 60deg 120deg
    );
  transform: scale(5);
  transform-origin: 50% 45%;
  animation: spin-slow 48s linear infinite;
}

.sunburst--soft {
  opacity: 0.55;
  animation-duration: 70s;
}

@keyframes spin-slow {
  from { transform: scale(5) rotate(0deg); }
  to { transform: scale(5) rotate(360deg); }
}

.confetti {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 22%, #B7410E 0 4px, transparent 5px),
    radial-gradient(circle at 88% 18%, #fff 0 5px, transparent 6px),
    radial-gradient(circle at 78% 72%, #8D4925 0 3px, transparent 4px),
    radial-gradient(circle at 18% 78%, #fff 0 4px, transparent 5px),
    radial-gradient(circle at 50% 12%, #F5E6BE 0 3px, transparent 4px);
  opacity: 0.85;
}

.brand-hero {
  position: relative;
  z-index: 1;
  text-align: center;
  margin-top: clamp(4px, 1.5vh, 16px);
  margin-bottom: 0;
  animation: rise-in 0.6s ease both;
  flex-shrink: 0;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand-logo {
  display: block;
  width: min(72vw, 280px);
  height: auto;
  margin: 0 auto 8px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  filter: none;
  animation: brand-pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 11vw, 3.6rem);
  letter-spacing: -0.03em;
  line-height: 0.95;
  margin-bottom: 10px;
  color: var(--outline);
  -webkit-text-stroke: 0;
  text-shadow:
    0 0 0 transparent,
    3px 3px 0 #FFE600,
    -2px -2px 0 #FFE600,
    2px -2px 0 #FFE600,
    -2px 2px 0 #FFE600,
    0 4px 0 rgba(59, 36, 20, 0.15);
  animation: brand-pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes brand-pop {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

.title-tiles {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-bottom: 7px;
}

.title-tiles--second {
  margin-bottom: 4px;
}

.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(40px, 10vw, 52px);
  height: clamp(44px, 11vw, 56px);
  border-radius: 14px;
  border: 3px solid var(--outline);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 4.8vw, 1.75rem);
  color: #fff;
  box-shadow: var(--tile-shadow);
  animation: tile-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.title-tiles .tile:nth-child(1) { animation-delay: 0.05s; }
.title-tiles .tile:nth-child(2) { animation-delay: 0.1s; }
.title-tiles .tile:nth-child(3) { animation-delay: 0.15s; }
.title-tiles .tile:nth-child(4) { animation-delay: 0.2s; }
.title-tiles .tile:nth-child(5) { animation-delay: 0.25s; }
.title-tiles--second .tile:nth-child(1) { animation-delay: 0.3s; }
.title-tiles--second .tile:nth-child(2) { animation-delay: 0.35s; }
.title-tiles--second .tile:nth-child(3) { animation-delay: 0.4s; }
.title-tiles--second .tile:nth-child(4) { animation-delay: 0.45s; }

@keyframes tile-in {
  from { opacity: 0; transform: translateY(20px) rotate(-8deg) scale(0.8); }
  to { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

/* Brand tile palette: red / yellow biscuit / white / orange */
/* Brand tile palette: jacket orange / cream / white / yellow */
.tile.c1, .answer-slot.c1 { background: linear-gradient(160deg, #D4561E, #B7410E); color: #fff; }
.tile.c2, .answer-slot.c2 { background: linear-gradient(160deg, #FFF8E7, #F5E6BE); color: #211A16; }
.tile.c3, .answer-slot.c3 { background: linear-gradient(160deg, #ffffff, #F3F3F3); color: #211A16; }
.tile.c4, .answer-slot.c4 { background: linear-gradient(160deg, #FFEE58, #FDD835); color: #211A16; }
.tile.c5, .answer-slot.c5 { background: linear-gradient(160deg, #8D4925, #6B3418); color: #fff; }
.tile.c6, .answer-slot.c6 { background: linear-gradient(160deg, #FFEB3B, #FBC02D); color: #211A16; }

@keyframes mascot-bounce {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-10px) rotate(1deg); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.play-group {
  position: absolute;
  top: 64%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn-play {
  position: relative;
  z-index: 1;
  margin-top: 0;
  width: 92px;
  height: 92px;
  border: 0;
  background: transparent;
  cursor: pointer;
  animation: pulse-ring 2.2s ease-in-out infinite;
  flex-shrink: 0;
}

.btn-play__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--outline);
  box-shadow: 0 8px 0 rgba(59, 36, 20, 0.18);
}

.btn-play__core {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: linear-gradient(160deg, #D4561E, #B7410E);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease;
}

.btn-play:active .btn-play__core {
  transform: scale(0.94);
}

@keyframes pulse-ring {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.play-label {
  position: relative;
  z-index: 1;
  margin-top: 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
}

.back-site {
  position: relative;
  z-index: 2;
  align-self: flex-start;
  margin-bottom: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.85rem;
}

.menu-tools {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
  justify-content: center;
}

.tool-btn,
.icon-btn {
  min-width: 48px;
  height: 44px;
  padding: 0 12px;
  border: 3px solid var(--outline);
  border-radius: 14px;
  background: var(--surface);
  color: var(--outline);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(59, 36, 20, 0.18);
  transition: transform 0.12s ease, background 0.2s;
}

.icon-btn {
  width: 48px;
  padding: 0;
  font-family: var(--font-display);
  font-size: 1rem;
}

.tool-btn[aria-pressed="false"] {
  opacity: 0.55;
}

.tool-btn:active,
.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(59, 36, 20, 0.18);
}

.highscore-line {
  position: relative;
  z-index: 1;
  margin-top: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}

.highscore-line strong {
  color: var(--accent);
  font-size: 1.15rem;
  font-family: var(--font-display);
}

/* HUD */
.hud {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.hud-stats {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 3px solid var(--outline);
  box-shadow: 0 3px 0 rgba(59, 36, 20, 0.15);
}

.stat small {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 800;
}

.stat strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.2;
  color: var(--outline);
}

.timer-stat.is-low strong {
  color: var(--danger);
  animation: blink 0.8s ease infinite;
}

@keyframes blink {
  50% { opacity: 0.5; }
}

.game-board {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.category-chip {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 3px solid var(--outline);
  font-size: 0.85rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--outline);
  box-shadow: 0 3px 0 rgba(59, 36, 20, 0.12);
}

.progress-text {
  position: relative;
  z-index: 1;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 16px;
}

.answer-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  margin-bottom: 24px;
  width: 100%;
}

.answer-slot {
  width: clamp(42px, 10vw, 52px);
  height: clamp(48px, 11vw, 58px);
  border-radius: 14px;
  border: 3px dashed rgba(59, 36, 20, 0.35);
  background: rgba(255, 255, 255, 0.35);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.answer-slot.filled {
  border-style: solid;
  border-color: var(--outline);
  box-shadow: var(--tile-shadow);
}

.answer-slot.hinted {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}

.answer-slot.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.letter-pool {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 360px;
  margin-bottom: 0;
  min-height: 0;
}

.pool-letter {
  width: clamp(48px, 12vw, 58px);
  height: clamp(52px, 13vw, 64px);
  border: 3px solid var(--outline);
  border-radius: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--tile-shadow);
  transition: transform 0.12s ease, opacity 0.15s;
}

.pool-letter:active:not(:disabled) {
  transform: translateY(3px) scale(0.96);
  box-shadow: 0 2px 0 rgba(59, 36, 20, 0.18);
}

.pool-letter:disabled,
.pool-letter.used {
  opacity: 0.28;
  cursor: default;
  transform: scale(0.9);
}

.pool-letter:nth-child(6n+1) {
  background: linear-gradient(160deg, #D4561E, #B7410E);
  color: #fff;
}
.pool-letter:nth-child(6n+2) {
  background: linear-gradient(160deg, #FFF8E7, #F5E6BE);
  color: #211A16;
}
.pool-letter:nth-child(6n+3) {
  background: linear-gradient(160deg, #ffffff, #F3F3F3);
  color: #211A16;
}
.pool-letter:nth-child(6n+4) {
  background: linear-gradient(160deg, #FFEE58, #FDD835);
  color: #211A16;
}
.pool-letter:nth-child(6n+5) {
  background: linear-gradient(160deg, #8D4925, #6B3418);
  color: #fff;
}
.pool-letter:nth-child(6n+6) {
  background: linear-gradient(160deg, #FFEB3B, #FBC02D);
  color: #211A16;
}

.game-actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
  flex-shrink: 0;
}

.action-btn,
.menu-btn {
  flex: 1;
  border: 3px solid var(--outline);
  border-radius: 14px;
  padding: 13px 12px;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--surface);
  color: var(--outline);
  box-shadow: 0 4px 0 rgba(59, 36, 20, 0.18);
  transition: transform 0.12s ease, background 0.2s;
}

.action-btn:active,
.menu-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(59, 36, 20, 0.18);
}

.action-btn--primary,
.menu-btn.primary {
  background: linear-gradient(160deg, #D4561E, #B7410E);
  color: #fff;
  border-color: var(--outline);
}

.modal-card {
  width: min(100%, 340px);
  padding: 26px 22px;
  border-radius: 24px;
  background: #fff;
  border: 4px solid var(--outline);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: #3B2414;
  box-shadow: 0 10px 0 rgba(59, 36, 20, 0.2);
  animation: rise-in 0.35s ease both;
}

.modal-card h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-bottom: 4px;
  color: #3B2414;
}

.help-list {
  text-align: left;
  padding-left: 1.2rem;
  color: #6B4A2E;
  line-height: 1.55;
  font-size: 0.95rem;
  margin-bottom: 8px;
  font-weight: 600;
}

.result-mascot {
  width: 96px;
  height: 96px;
  object-fit: cover;
  object-position: center 18%;
  border-radius: 50%;
  border: 3px solid #211A16;
  margin: 0 auto;
  background: var(--cream);
  animation: mascot-bounce 2.4s ease-in-out infinite;
}

.result-word {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.result-score,
.result-high {
  color: #6B4A2E;
  font-weight: 700;
}

.result-score strong {
  color: #3B2414;
  font-size: 1.2rem;
}

.answer-row.correct .answer-slot.filled {
  animation: pop-correct 0.45s ease both;
}

@keyframes pop-correct {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% {
    transform: scale(1);
    background: linear-gradient(160deg, #69DB7C, #2F9E44) !important;
    color: #fff !important;
  }
}

.answer-row.wrong .answer-slot.filled {
  animation: shake 0.4s ease;
  background: linear-gradient(160deg, #FF6B6B, #E31C23) !important;
  color: #fff !important;
}

@media (max-height: 720px) {
  .brand-logo {
    width: min(58vw, 200px);
  }
  .brand-mark {
    font-size: clamp(2.1rem, 9vw, 2.8rem);
  }
}

@media (max-height: 600px) {
  .tile { width: 36px; height: 40px; font-size: 1.1rem; }
  .btn-play { width: 72px; height: 72px; }
}
