/* Spelling Bee-line — styles. A bright honey page with a faint honeycomb, an
   amber bar with 70s stripes, letters in hexagon tiles, and a friendly bee. */
:root {
  --bg: #fdf6e3;
  --panel: #ffffff;
  --text: #2a2420;
  --muted: #6b625a;
  --line: #e4dccb;
  --honey: #e89a00;
  --honey-dark: #8a5200;
  --honey-soft: #fff4d6;
  --go: #e2622c;
  --go-dark: #b84a1c;
  --mustard: #f2b134;
  --right: #2fa35a;
  --wrong: #d0402e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cpath d='M28 0L56 16v32L28 64 0 48V16zM28 64l28 16v32M28 64L0 80v32' fill='none' stroke='%23f3e2b3' stroke-width='1.5'/%3E%3C/svg%3E"); color: var(--text); display: flex; flex-direction: column; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button {
  font: inherit; font-weight: 700; border: 2px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 12px; padding: 8px 16px; cursor: pointer; touch-action: manipulation;
}
button:disabled { opacity: .45; cursor: default; }
button.go { background: var(--go); border-color: var(--go-dark); color: #fff; font-size: 18px; padding: 10px 22px; }
button.go:not(:disabled):hover { background: var(--go-dark); }
button.secondary { background: #fff; }
button.danger { color: var(--wrong); border-color: #f0c4be; }
button.icon { width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 20px; }
button.plain { border: none; background: none; }
.small { color: var(--muted); font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; background: var(--honey); color: #fff;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark { font-size: 22px; background: #fff; border-radius: 8px; padding: 0 4px; line-height: 1.3; }
.top-right { display: flex; gap: 8px; align-items: center; }
.top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.apps-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px; box-sizing: border-box; padding: 6px 14px;
  border-radius: 999px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .5);
  color: #fff; text-decoration: none; font-weight: 700; font-size: 16px;
}
.apps-link:hover { background: rgba(255, 255, 255, .3); }
.apps-link svg { fill: currentColor; flex: none; }
.player-chip { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .5); padding: 6px 14px; }
.topbar button.icon { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .5); }
.topbar, .stripes, .update-note { flex-shrink: 0; }
.stripes { height: 9px; background: linear-gradient(var(--mustard) 0 3px, var(--go) 3px 6px, #8a4b2a 6px 9px); }
.update-note {
  display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px; background: #fff4d6;
  border-bottom: 1px solid #f0d58a; font-weight: 600;
}

/* ---------- home ---------- */
.home { max-width: 1000px; width: 100%; margin: 0 auto; padding: 12px 14px 0; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; }
.home h2 { margin: 0 0 10px; font-size: 18px; color: var(--honey-dark); display: flex; align-items: baseline; gap: 10px; }
.home-total { margin-left: auto; color: #c48a00; font-size: 16px; }
.players { display: flex; flex-wrap: wrap; gap: 10px; }
.player { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 30px; border: 3px solid var(--line); }
.player-emoji { font-size: 28px; line-height: 1; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #f6f1e4; }
.player.on { border-color: var(--pc, var(--honey)); background: color-mix(in srgb, var(--pc, var(--honey)) 10%, #fff); }
.player.add { color: var(--muted); border-style: dashed; }
.player-badges { font-size: 18px; letter-spacing: 1px; margin-left: 2px; }
.brand-bee { display: inline-block; width: 40px; height: 34px; background: #fff; border-radius: 10px; padding: 2px 3px; }
.brand-bee svg { width: 100%; height: 100%; display: block; }
.grades { display: flex; flex-direction: column; gap: 8px; }
.grade { display: grid; grid-template-columns: 190px 1fr; gap: 10px; align-items: center; }
.grade-name { font-weight: 800; color: var(--honey-dark); display: flex; align-items: center; gap: 10px; line-height: 1.15; }
.grade-name > span:last-child { display: flex; flex-direction: column; gap: 3px; }
.grade-hex {
  width: 40px; height: 36px; flex: none; display: grid; place-items: center; font-weight: 900; font-size: 18px; color: #3a2a1a;
  background: #ffc928; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}
.grade-levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.lvl { display: flex; flex-direction: column; align-items: center; padding: 4px 3px; border-width: 3px; min-width: 0; }
.lvl-icon { font-size: 20px; line-height: 1.1; }
.lvl-name { font-size: 12.5px; line-height: 1.15; text-align: center; }
.lvl-stars { color: #f2b705; letter-spacing: 1px; font-size: 13px; }
.lvl.on { border-color: var(--go); background: #fff1e8; }
.lvl.locked { background: #f4f1ea; color: var(--muted); border-style: dashed; }
.lvl.locked .lvl-stars { opacity: .4; }
.level-about { margin: 10px 2px 0; color: var(--muted); font-weight: 600; }
.home-go {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; position: sticky; bottom: 0; z-index: 2;
  padding: 10px 0 12px; background: linear-gradient(rgba(253, 246, 227, 0), var(--bg) 30%);
}
.home-go .go { font-size: 22px; padding: 12px 36px; }

/* ---------- a round ---------- */
.play { flex: 1; display: grid; grid-template-rows: auto 1fr auto; gap: 6px; padding: 6px 12px 10px; min-height: 0; max-width: 1100px; width: 100%; margin: 0 auto; }
.play-bar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.bar-title { font-weight: 800; font-size: 18px; color: var(--honey-dark); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comb { display: flex; gap: 3px; }
.comb .cell {
  width: 24px; height: 21px; background: #e9dcc0; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}
.comb .cell.full { background: radial-gradient(circle at 40% 35%, #ffe27a, #f5a700); }
.comb .cell.half { background: linear-gradient(#e9dcc0 50%, #f5b400 50%); }
.comb .cell.miss { background: #cfc6b4; }
.comb .cell.now { background: #fff; box-shadow: inset 0 0 0 3px #f5a700; outline: 3px solid #f5a700; }
.streak {
  font-weight: 900; font-size: 18px; color: #8a5200; background: #fff4d6; border: 2px solid #f5c04a; border-radius: 999px; padding: 2px 12px;
}
.streak.bump { animation: pop .35s ease-out; }

.stage {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 0;
  background: rgba(255, 255, 255, .7); border: 2px solid #f1dfb0; border-radius: 22px; padding: 10px 14px;
}
.say-row { display: flex; align-items: center; gap: 12px; max-width: 900px; width: 100%; justify-content: center; }
.say-btn {
  width: 58px; height: 58px; flex: none; border-radius: 50%; font-size: 28px; padding: 0; border: 3px solid #f5c04a; background: #fff8e1;
  box-shadow: 0 3px 0 #e0b443;
}
.say-btn:active { translate: 0 2px; box-shadow: 0 1px 0 #e0b443; }
.sentence { font-size: 21px; font-weight: 600; color: #4a3a22; line-height: 1.35; }
.sentence .blank { letter-spacing: 2px; color: #c48a00; font-weight: 900; }

.word-area { position: relative; width: 100%; container-type: inline-size; padding-top: 66px; margin-top: 4px; --n: 5; }
.word { --tw: min(88px, calc((100cqw - 10px) / var(--n) - 8px)); display: flex; justify-content: center; gap: 8px; }
.tile {
  width: var(--tw); aspect-ratio: 1.12; padding: 4px; border: none; border-radius: 0; background: #c98a00; position: relative;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); font: 900 calc(var(--tw) * .55)/1 system-ui, sans-serif;
  color: #3a2a1a; cursor: default; transition: transform .2s;
}
.tile > span {
  display: grid; place-items: center; width: 100%; height: 100%; background: radial-gradient(circle at 40% 30%, #fff3c2, #ffd75e 70%);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}
.tile.blank { background: #e0c27a; cursor: pointer; }
.tile.blank > span { background: #fffdf5; color: #2f6fe0; }
.tile.active { background: #f57c00; animation: tileGlow 1s ease-in-out infinite; }
@keyframes tileGlow { 50% { background: #ffb74d; } }
.tile.typed > span { background: #eef5ff; }
.tile.hinted > span { background: #fff0c8; color: #8a5200; }
.tile.wrong { background: #d0402e; }
.tile.wrong > span { background: #ffe1dc; color: #b3261e; }
.tile.shown { background: #f57c00; }
.tile.shown > span { background: #ffe6c7; color: #b45309; }
.tile.right { background: #2fa35a; }
.tile.right > span { background: radial-gradient(circle at 40% 30%, #eaffd9, #a7e38a 75%); color: #1d5c34; }
.tile.movable { cursor: grab; }
.tile.sel { transform: translateY(-14px); background: #f57c00; }
.tile.hintme { animation: tileGlow .8s ease-in-out infinite; background: #f57c00; }
.tile.gap { background: #e0c27a; cursor: pointer; }
.tile.gap > span { background: #fff8e6; }
.tile.gap.sel { transform: none; background: #f57c00; }
.tile.swapped { animation: swapHop .3s ease-out; }
@keyframes swapHop { 40% { transform: translateY(-12px) scale(1.06); } }
.word.showing .tile { animation: showPulse 1s ease-in-out 2; }
@keyframes showPulse { 50% { transform: scale(1.06); } }
.drag-ghost { position: fixed; z-index: 50; width: 70px; pointer-events: none; transform: translate(-50%, -60%) scale(1.1); filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .3)); }
.peek {
  position: absolute; inset: auto 0 0 0; margin: auto; width: fit-content; padding: 6px 24px; border-radius: 16px; z-index: 3;
  background: #3a2a1a; color: #ffd75e; font: 900 44px/1.2 system-ui, sans-serif; letter-spacing: 6px; bottom: 6px;
}
.peek.show { animation: peekIn 1.6s ease-in-out forwards; }
@keyframes peekIn { 0% { opacity: 0; scale: .8; } 12% { opacity: 1; scale: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* the bee, hovering over the letter being typed */
.bee {
  --at: 2; position: absolute; top: 8px; width: 64px; height: 54px; pointer-events: none; z-index: 2;
  left: calc(50% + (var(--at) - (var(--n) - 1) / 2) * (min(88px, calc((100cqw - 10px) / var(--n) - 8px)) + 8px) - 32px);
  transition: left .35s cubic-bezier(.3, 1.4, .5, 1); animation: hover 1.4s ease-in-out infinite;
}
.bee svg { width: 100%; height: 100%; }
.bee .wing { transform-box: fill-box; transform-origin: bottom center; animation: flap .12s linear infinite alternate; }
@keyframes flap { to { scale: 1 .6; } }
@keyframes hover { 50% { translate: 0 -6px; } }
.bee.loop { animation: beeLoop 1.1s ease-in-out; }
@keyframes beeLoop { 0% { transform: none; } 30% { transform: translate(40px, -30px) rotate(25deg); } 60% { transform: translate(-30px, -40px) rotate(-20deg); } 100% { transform: none; } }

.prompt { font-size: 19px; font-weight: 800; color: #4a3a22; min-height: 1.4em; text-align: center; }
.prompt.good { color: #1d7a42; font-size: 24px; animation: pop .35s ease-out; }
.prompt.bad { color: #b3261e; }
.prompt.nudge { color: #b45309; animation: pop .3s ease-out; }
.prompt.shown { color: #b45309; }
.tray {
  display: flex; gap: 8px; justify-content: center; align-items: center; min-height: 82px; min-width: min(520px, 90%); padding: 6px 12px;
  border: 3px dashed #e0c27a; border-radius: 18px; background: #fffaf0;
}
.tray .tile { --tw: 66px; width: 66px; }
.tray-empty { color: #b9a37a; font-weight: 700; }

.bottom { display: flex; align-items: center; justify-content: center; gap: 16px; }
.helps { display: flex; flex-direction: column; gap: 8px; }
.help-btn { display: flex; align-items: center; gap: 6px; font-size: 15px; padding: 6px 12px; border-width: 3px; border-color: #f1dfb0; }
.help-btn span { font-size: 20px; }
.keys { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 0 16px; border-left: 3px dashed #ead6a6; border-right: 3px dashed #ead6a6; }
.key-row { display: flex; gap: 6px; }
.key {
  width: 52px; height: 50px; padding: 0; font: 800 24px/1 system-ui, sans-serif; border-radius: 12px; border: 2px solid #e2cf9f;
  background: #fffdf6; box-shadow: 0 4px 0 #e2cf9f; color: #3a2a1a;
}
.key:active, .key.down { translate: 0 3px; box-shadow: 0 1px 0 #e2cf9f; }
.controls { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.ctl { border: none; padding: 0; display: grid; place-items: center; position: relative; }
.ctl svg { width: 60%; height: 60%; }
.check-btn {
  width: 120px; height: 72px; border-radius: 999px; background: radial-gradient(circle at 35% 30%, #7ee2a2, #22b35e 60%, #14763c);
  box-shadow: 0 6px 0 #11612f, 0 8px 12px rgba(0, 0, 0, .25);
}
.check-btn svg { height: 62%; width: auto; }
.check-btn:not(.ready) { filter: saturate(.3) brightness(.95); }
.check-btn.ready { animation: readyGlow 1.2s ease-in-out infinite; }
@keyframes readyGlow { 50% { box-shadow: 0 6px 0 #11612f, 0 0 18px 4px rgba(63, 200, 120, .6); } }
.back-btn {
  width: 58px; height: 58px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #c9c6d8, #8d8aa3 60%, #5d5a70);
  box-shadow: 0 5px 0 #4a475a, 0 7px 10px rgba(0, 0, 0, .25);
}
.ctl:active { translate: 0 4px; }

.result {
  position: absolute; inset: 0; margin: auto; width: min(430px, 94%); height: fit-content; background: #fff; border-radius: 18px;
  border: 4px solid #f5c04a; box-shadow: 0 10px 40px rgba(120, 80, 0, .25); padding: 16px 20px; text-align: center; z-index: 4;
}
.result-stars { font-size: 46px; color: #f2b705; letter-spacing: 4px; }
.result-text { font-size: 26px; font-weight: 800; color: var(--honey-dark); }
.result-detail { color: var(--muted); font-weight: 600; margin: 6px 0 10px; }
.result-buttons { display: flex; gap: 10px; justify-content: center; }

/* ---------- dialogs ---------- */
.dialog { max-width: 460px; width: calc(100% - 28px); border: none; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.dialog.wide { max-width: 760px; }
.dialog::backdrop { background: rgba(70, 45, 0, .45); }
.dialog h2 { margin: 0 0 12px; color: var(--honey-dark); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; margin-bottom: 12px; }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field input[type=text], .field select { font: inherit; font-weight: 500; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; }
.field input[type=checkbox] { width: 22px; height: 22px; flex: none; }
.field-label { font-weight: 700; margin-bottom: 6px; }
.emoji-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 14px; }
.emoji-pick button { font-size: 26px; padding: 4px 0; border-radius: 10px; }
.emoji-pick button.on { border-color: var(--honey); background: var(--honey-soft); }
.dialog-buttons { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.spacer { flex: 1; }
.help li { margin-bottom: 8px; line-height: 1.45; }
.scores { border-collapse: collapse; width: 100%; font-size: 15px; }
.scores th, .scores td { padding: 6px 5px; border-bottom: 1px solid var(--line); text-align: center; }
.scores th { font-size: 22px; }
.scores .who { text-align: left; white-space: nowrap; font-weight: 700; }
.scores small { color: #f2b705; margin-left: 4px; }
.scores td.top { font-weight: 900; color: #b45309; }
.scores .hs-track td { font-weight: 900; background: #f6f1ff; text-align: left; }
.scores .lvl-cell { text-align: left; }
#scores { overflow-x: auto; }

/* ---------- rewards: streaks, badges, celebrations ---------- */
.streak {
  font-weight: 900; font-size: 18px; color: #c2410c; background: #fff1e0; border: 2px solid #f6b98a; border-radius: 999px;
  padding: 2px 12px; white-space: nowrap;
}
.streak.bump { animation: pop .35s ease-out; }
.grade-badge {
  font-size: 11.5px; font-weight: 800; color: #a59a88; border: 2px dashed #ddd3bf; border-radius: 999px; padding: 1px 8px;
  width: fit-content; white-space: nowrap;
}
.grade-badge.won { color: #7a5200; background: linear-gradient(#fff3c4, #f7d36a); border: 2px solid #d9a521; box-shadow: 0 1px 0 #c08f12; }
.player-badges { font-size: 18px; letter-spacing: 1px; margin-left: 2px; }
.result-rewards { list-style: none; padding: 0; margin: -6px 0 14px; display: flex; flex-direction: column; gap: 4px; font-weight: 800; color: #7a4a00; }
.result-rewards li { background: #fff6dc; border-radius: 10px; padding: 4px 10px; }
.result-rewards:empty { display: none; }

.toast {
  position: fixed; left: 50%; top: 84px; transform: translateX(-50%); z-index: 20; pointer-events: none;
  background: #c2410c; color: #fff; font-weight: 900; font-size: 20px; padding: 8px 20px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(194, 65, 12, .35);
}
.toast.show { animation: toastIn 2.2s ease-out forwards; }
@keyframes toastIn {
  0% { opacity: 0; translate: 0 -12px; scale: .8; } 12% { opacity: 1; translate: 0 0; scale: 1.08; } 20% { scale: 1; }
  80% { opacity: 1; } 100% { opacity: 0; translate: 0 -8px; }
}

.celebrate { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(90, 60, 0, .45); overflow: hidden; }
.cel-card {
  position: relative; z-index: 2; background: #fff; border-radius: 22px; border: 4px solid var(--mustard); padding: 22px 28px 20px;
  width: min(420px, 90%); text-align: center; box-shadow: 0 16px 50px rgba(90, 60, 0, .4); animation: celIn .5s cubic-bezier(.2, 1.6, .4, 1);
}
.cel-icon { font-size: 72px; line-height: 1.1; animation: wiggle 1.2s ease-in-out .4s 2; }
.celebrate.badge .cel-icon {
  width: 120px; height: 120px; margin: 0 auto 6px; display: grid; place-items: center; font-size: 62px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8d6, #f7d36a 60%, #d9a521); border: 5px solid #c08f12;
  box-shadow: 0 0 0 6px #fff3c4, 0 0 30px 10px rgba(247, 211, 106, .7);
}
.cel-title { font-size: 30px; font-weight: 900; color: var(--honey-dark); margin-top: 4px; }
.cel-text { color: var(--muted); font-weight: 600; margin: 8px 0 16px; line-height: 1.4; }
@keyframes celIn { from { scale: .4; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes wiggle { 0%, 100% { rotate: 0deg; } 25% { rotate: -12deg; } 75% { rotate: 12deg; } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; opacity: 0;
  animation-name: fall; animation-timing-function: cubic-bezier(.3, .6, .6, 1); animation-fill-mode: forwards;
}
.confetti i.round { width: 12px; height: 12px; border-radius: 50%; }
@keyframes fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: .9; transform: translate(var(--drift), 105vh) rotate(var(--spin)); }
}
/* ---------- smaller screens ---------- */
@media (max-height: 700px) {
  .home { gap: 8px; }
  .panel { padding: 8px 12px; }
  .stage { padding: 6px 12px; gap: 4px; }
  .word-area { padding-top: 56px; }
  .bee { width: 54px; height: 46px; }
  .say-btn { width: 50px; height: 50px; font-size: 24px; }
  .sentence { font-size: 18px; }
  .key { width: 48px; height: 44px; font-size: 22px; }
  .check-btn { width: 108px; height: 62px; }
  .back-btn { width: 52px; height: 52px; }
  .tray { min-height: 70px; }
  .tray .tile { width: 56px; }
}
@media (max-width: 900px) {
  .grade { grid-template-columns: 1fr; gap: 4px; }
  .grade-name > span:last-child { flex-direction: row; align-items: center; gap: 8px; }
}
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .bottom { flex-wrap: wrap; gap: 10px; }
  .keys { order: -1; width: 100%; border: none; padding: 0; }
  .key { width: calc((100vw - 90px) / 10); max-width: 52px; }
  .helps { flex-direction: row; }
  .controls { flex-direction: row-reverse; padding-left: 14px; border-left: 3px dashed #ead6a6; }
}
@media (max-width: 700px) {
  .apps-link span { display: none; }
  .brand { font-size: 18px; }
  .comb .cell { width: 18px; height: 16px; }
}
@media (max-width: 420px) {
  .brand { font-size: 15px; }
}
@keyframes pop { 0% { scale: .7; } 70% { scale: 1.12; } 100% { scale: 1; } }
#play[data-kind=swap] .helps, #play[data-kind=fix] .helps { flex-direction: row; }

.voice-row { display: flex; gap: 8px; }
.voice-row select { flex: 1; min-width: 0; font: inherit; font-weight: 500; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; }
