/* DeepSpelling — warm, big, touch-first. iPad friendly. */

:root {
  --honey: #f6c945;
  --honey-dark: #e8a020;
  --honey-soft: #ffe9a8;
  --bg: #fff8e7;
  --ink: #3a3226;
  --muted: #8a7f66;
  --good: #3e9c4f;
  --bad: #d9534f;
  --card: #ffffff;
  --hex: 96px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: linear-gradient(180deg, #fff3cf 0%, var(--bg) 40%);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 12px 32px;
  user-select: none;
}

header { text-align: center; margin: 8px 0 4px; }
h1 { font-size: 34px; margin: 0; letter-spacing: 1px; }
.tagline { color: var(--muted); font-size: 14px; }

main { width: 100%; max-width: 420px; flex: 1; }

.panel { background: var(--card); border-radius: 24px; padding: 20px; box-shadow: 0 8px 30px rgba(90, 70, 20, .12); }

.hidden { display: none !important; }

.field-label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

input#theme {
  width: 100%; font-size: 20px; padding: 14px 16px; border-radius: 14px;
  border: 2px solid #eadfbe; background: #fffdf5; color: var(--ink); margin-bottom: 12px;
}
input#theme:focus { outline: none; border-color: var(--honey-dark); }

.mode-row { display: flex; gap: 10px; margin-bottom: 14px; }
.mode {
  flex: 1; font-size: 18px; font-weight: 700; padding: 12px 0; border-radius: 14px;
  border: 2px solid #eadfbe; background: #fffdf5; color: var(--muted); cursor: pointer;
}
.mode.active { background: var(--honey); border-color: var(--honey-dark); color: var(--ink); }

button { font-family: inherit; cursor: pointer; }
.big {
  width: 100%; font-size: 22px; font-weight: 800; padding: 16px; border: none;
  border-radius: 16px; background: var(--honey); color: var(--ink);
  box-shadow: 0 4px 0 var(--honey-dark); transition: transform .05s;
}
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--honey-dark); }

.hint-line { color: var(--muted); font-size: 13px; text-align: center; margin: 12px 0 0; }

/* --- game view --- */
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  background: #fdf3d5; border: 1px solid #ecd9a2; border-radius: 999px;
  padding: 6px 12px; font-size: 14px; font-weight: 600;
}
.progress { height: 10px; background: #f2e8c8; border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
#progress-bar { height: 100%; width: 0%; background: var(--good); border-radius: 999px; transition: width .25s; }

/* honeycomb */
#board { position: relative; width: 100%; height: 330px; margin: 0 auto; }
.hex {
  position: absolute; width: var(--hex); height: var(--hex);
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 800; color: var(--ink);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--honey-soft);
  transition: transform .06s;
}
.hex.center { background: var(--honey); box-shadow: 0 6px 18px rgba(232, 160, 32, .45); }
.hex:active { transform: translate(-50%, -50%) scale(.92); filter: brightness(.94); }
.hex.center { transform: translate(-50%, -50%); }
.hex:not(.center) { transform: translate(-50%, -50%); }
.hex.p-0 { left: 35%; top: 26%; }
.hex.p-1 { left: 65%; top: 26%; }
.hex.p-2 { left: 20%; top: 50%; }
.hex.p-3 { left: 80%; top: 50%; }
.hex.p-4 { left: 35%; top: 74%; }
.hex.p-5 { left: 65%; top: 74%; }
.hex.p-c { left: 50%; top: 50%; }

/* current word + controls */
#current-word {
  text-align: center; font-size: 34px; font-weight: 800; letter-spacing: 4px;
  min-height: 46px; margin: 6px 0 10px; color: var(--ink);
}
.controls { display: flex; justify-content: center; gap: 18px; margin-bottom: 8px; }
.ctl {
  width: 72px; height: 72px; border-radius: 50%; border: none; font-size: 30px; font-weight: 800;
  background: #f0e6c8; color: var(--ink); box-shadow: 0 4px 0 #d9cb9f;
}
.ctl.submit { background: var(--good); color: #fff; box-shadow: 0 4px 0 #2e7a3c; }
.ctl:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9cb9f; }

#message {
  min-height: 26px; text-align: center; font-size: 16px; font-weight: 600;
  margin: 4px 0 10px; transition: opacity .3s;
}
#message.ok { color: var(--good); }
#message.err { color: var(--bad); }

.actions { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.small {
  font-size: 15px; font-weight: 700; padding: 10px 14px; border-radius: 12px;
  border: 2px solid #eadfbe; background: #fffdf5; color: var(--ink);
}
.small.on { background: #fdf3d5; border-color: var(--honey-dark); }
.small.danger { color: var(--bad); border-color: #f0c8c6; }

#found-wrap { border-top: 2px dashed #eadfbe; padding-top: 12px; }
#found { display: flex; flex-wrap: wrap; gap: 8px; max-height: 150px; overflow-y: auto; }
.wchip {
  background: #eef7ef; border: 1px solid #b8d9bd; color: #27633a;
  border-radius: 999px; padding: 6px 12px; font-size: 15px; font-weight: 700;
}
.wchip.pangram { background: var(--honey); border-color: var(--honey-dark); color: var(--ink); }

/* reveal overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(58, 50, 38, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10;
}
.card {
  background: var(--card); border-radius: 24px; padding: 24px; width: 100%; max-width: 400px;
  max-height: 85vh; overflow-y: auto; text-align: center;
}
.card h2 { margin: 0 0 10px; }
#reveal-body { text-align: left; font-size: 16px; line-height: 1.5; }
#reveal-body .missed { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
#reveal-body .missed span {
  background: #fdecec; border: 1px solid #f0c8c6; color: #9c2f2b;
  border-radius: 999px; padding: 6px 12px; font-weight: 700; cursor: pointer;
}
#reveal-body .missed span.ok {
  background: #eef7ef; border-color: #b8d9bd; color: #27633a;
}
#reveal-body .scoreline { font-size: 24px; font-weight: 800; text-align: center; margin: 10px 0; white-space: pre-line; line-height: 1.6; }
#btn-again { margin-top: 14px; }

/* loading overlay (shown while the AI prepares a puzzle) */
.loading-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 28px; }
.spinner {
  width: 54px; height: 54px; border-radius: 50%;
  border: 6px solid var(--honey-soft);
  border-top-color: var(--honey-dark);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 20px; font-weight: 800; }
.loading-sub { color: var(--muted); font-size: 14px; }

footer { color: var(--muted); font-size: 12px; margin-top: 18px; text-align: center; }

/* home screen */
.home-title { text-align: center; margin: 4px 0 14px; font-size: 22px; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.theme-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px; border-radius: 16px; border: 2px solid #eadfbe;
  background: #fffdf5; color: var(--ink); font-size: 15px; font-weight: 700;
  transition: transform .05s;
}
.theme-btn:active { transform: scale(.96); background: var(--honey-soft); }
.theme-btn:disabled, .mode:disabled { opacity: .55; cursor: default; }

/* KET topic section (collapsible, closed by default) */
.ket-wrap { margin-bottom: 12px; }
.ket-wrap summary {
  list-style: none; cursor: pointer; text-align: center;
  font-size: 17px; font-weight: 800; padding: 12px;
  border-radius: 14px; border: 2px solid #eadfbe; background: #fffdf5; color: var(--ink);
}
.ket-wrap summary::-webkit-details-marker { display: none; }
.ket-wrap summary::after { content: ' ▾'; }
.ket-wrap[open] summary::after { content: ' ▴'; }
.ket-grid { margin-top: 10px; }
.t-emoji { font-size: 40px; line-height: 1.1; }
#setup-msg { min-height: 22px; text-align: center; font-weight: 600; color: var(--bad); margin-top: 8px; font-size: 15px; }
#honey-link { display: block; margin: 0 auto 10px; }
#honey-form { border-top: 2px dashed #eadfbe; padding-top: 12px; margin-top: 4px; }

/* classic view */
.hear-btn {
  display: block; width: 100%; font-size: 26px; font-weight: 800; padding: 18px;
  border: none; border-radius: 16px; background: var(--honey); color: var(--ink);
  box-shadow: 0 4px 0 var(--honey-dark); margin-bottom: 12px;
}
.hear-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--honey-dark); }

.q-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }

#c-emoji { font-size: 76px; line-height: 1.1; text-align: center; margin: 4px 0 8px; }

.spell-row { display: flex; gap: 8px; margin-bottom: 12px; }
#c-spelling {
  flex: 1; min-width: 0; font-size: 22px; padding: 14px 16px; border-radius: 14px;
  border: 2px solid #eadfbe; background: #fffdf5; color: var(--ink);
  text-transform: uppercase; letter-spacing: 2px;
}
#c-spelling:focus { outline: none; border-color: var(--honey-dark); }
.mic-btn {
  width: 62px; border-radius: 14px; border: 2px solid #eadfbe; background: #fffdf5;
  font-size: 26px; cursor: pointer;
}
.mic-btn.listening { background: #fdecec; border-color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(.92); } }

#c-message { min-height: 26px; text-align: center; font-size: 16px; font-weight: 600; margin: 10px 0; white-space: pre-line; line-height: 1.5; }
#c-message.ok { color: var(--good); }
#c-message.err { color: var(--bad); }

.home-row { display: flex; justify-content: center; gap: 8px; margin-top: 6px; }

/* on-screen letter keyboard */
.letters { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.letter-btn {
  padding: 10px 0; font-size: 20px; font-weight: 800; border-radius: 10px;
  border: 2px solid #eadfbe; background: #fffdf5; color: var(--ink);
}
.letter-btn:active { background: var(--honey-soft); }
.letter-btn:disabled { opacity: .25; }
.letter-btn.util { background: #f0e6c8; font-size: 16px; }

@media (max-width: 380px) {
  :root { --hex: 78px; }
  #board { height: 285px; }
  .ctl { width: 62px; height: 62px; font-size: 26px; }
  #current-word { font-size: 28px; }
}
