/* Starfruit — tropical pixel art. No rounded corners, no blur. */
:root {
  --water: #1fb5c4;
  --water-deep: #0f7f98;
  --water-light: #9fe8e8;
  --sky: #7fd8ec;
  --sand: #f4d58d;
  --sand-light: #fff4d6;
  --sand-dark: #d9b56a;
  --palm: #2e9e4f;
  --palm-dark: #1d6b37;
  --coral: #ff6f61;
  --orange: #ff9f1c;
  --sun: #ffd23f;
  --navy: #13223f;
  --navy-soft: #3a4a6b;
  --white: #fffdf5;

  --t-coconut: #8a6a4a;
  --t-mango: #ff9f1c;
  --t-pineapple: #e0b400;
  --t-starfruit: #ff6f61;
  --t-driftwood: #7a6a5a;

  --px: 4px;              /* border width */
  --shadow: 4px 4px 0 var(--navy);
  --font-head: "Press Start 2P", ui-monospace, monospace;
  --font-body: "VT323", ui-monospace, "Cascadia Mono", Menlo, monospace;
  --vvh: 100vh;
  --vvtop: 0px;
  --gap: 12px;
  --box: min(60px, calc((100vw - 32px - 4 * 8px) / 5));
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  color: var(--navy);
  font-family: var(--font-body);
  font-size: 22px; /* VT323 at 22px reads like ~16px text */
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; }

#scene {
  position: fixed;
  left: 0;
  top: var(--vvtop);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 0;
}

#app {
  position: fixed;
  left: 0; right: 0;
  top: var(--vvtop);
  height: var(--vvh);
  z-index: 1;
  display: flex;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
}

.screen {
  width: 100%;
  max-width: 460px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--gap);
  min-height: 0;
}
.screen[hidden] { display: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- panels & buttons ---------- */
.panel {
  background: var(--sand-light);
  border: var(--px) solid var(--navy);
  box-shadow: var(--shadow);
  padding: 16px;
}
.center { text-align: center; }

.btn {
  font-family: var(--font-head);
  font-size: 13px;
  line-height: 1.4;
  color: var(--navy);
  background: var(--white);
  border: var(--px) solid var(--navy);
  box-shadow: var(--shadow);
  min-height: 48px;
  padding: 10px 16px;
  cursor: pointer;
  text-transform: uppercase;
  border-radius: 0;
  touch-action: manipulation;
}
.btn:hover { background: #fff8e6; }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--navy); }
.btn-primary { background: var(--orange); }
.btn-primary:hover { background: #ffb347; }
.btn:disabled { background: #d8d2c2; color: #6d6a63; cursor: not-allowed; box-shadow: 2px 2px 0 var(--navy-soft); border-color: var(--navy-soft); }

:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
.btn:focus-visible { outline: 4px solid var(--navy); outline-offset: 3px; box-shadow: var(--shadow), 0 0 0 3px var(--sun); }

.btn-col { display: flex; flex-direction: column; gap: 14px; margin: 16px 0; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 12px 0 6px; }
.btn-row .btn { flex: 1 1 140px; }

/* ---------- home ---------- */
.home-panel { text-align: center; }
.title {
  font-family: var(--font-head);
  font-size: clamp(20px, 7vw, 30px);
  line-height: 1.35;
  margin: 4px 0 12px;
  color: var(--navy);
  text-shadow: 3px 3px 0 var(--sun);
}
.title span { display: block; }
.title-accent { color: var(--water-deep); text-shadow: 2px 2px 0 var(--sand); font-size: clamp(10px, 3.2vw, 13px); margin-top: 10px; }
[hidden] { display: none !important; }

/* home: stat cards */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 12px; }
.stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--white);
  border: 3px solid var(--navy);
  box-shadow: 3px 3px 0 var(--navy);
  padding: 8px 4px 7px;
  min-width: 0;
}
.stat b { font-family: var(--font-head); font-size: 18px; line-height: 1.2; color: var(--navy); white-space: nowrap; }
.stat-lbl {
  margin-top: 6px;
  font-family: var(--font-head); font-size: 8px; line-height: 1.3;
  letter-spacing: 1px; text-transform: uppercase; color: var(--water-deep);
}

/* home: this week */
.week { list-style: none; margin: 0 0 14px; padding: 0; display: flex; justify-content: center; gap: 6px; }
.week li { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.wk-box {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 3px dashed #b9ab88;
  font-size: 14px; line-height: 1;
}
.wk-done { border: 3px solid var(--navy); background: var(--water-light); }
.wk-part { border: 3px solid var(--navy-soft); background: var(--sand); }
.wk-today .wk-box:not(.wk-done) { border-color: var(--orange); background: #fff0d6; }
.wk-today .wk-done { box-shadow: 0 0 0 2px var(--orange); }
.wk-name { font-size: 18px; color: var(--navy-soft); }
.wk-today .wk-name { color: #c76d00; font-weight: bold; }
.wk-future { opacity: .5; }

.btn-big { width: 100%; font-size: 15px; min-height: 56px; letter-spacing: 1px; }
.acct { margin-top: 10px; }
.save-note { margin: 0 0 10px; font-size: 20px; line-height: 1.1; color: var(--navy-soft); }
.acct .btn-row { margin: 0; }
.btn-sun { background: var(--sun); }
.btn-sun:hover { background: #ffe07a; }
.btn-ink { background: var(--navy); color: var(--white); border-color: var(--navy); }
.btn-ink:hover { background: #22365e; }
.btn-small { min-height: 44px; font-size: 11px; padding: 8px 14px; }
.home-foot { margin: 14px 0 0; font-size: 19px; line-height: 1.15; color: var(--navy-soft); }
.home-foot .cd { font-size: 11px; }
.linklike {
  background: none; border: 0; padding: 6px 2px; margin: 0;
  min-height: 32px;
  font: inherit; color: #0b6e86; text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.linklike:hover { color: var(--navy); }
.sum-acct { margin: 6px 0 0; }

/* log in / create account */
.auth {
  width: min(400px, calc(100vw - 32px));
  max-height: calc(var(--vvh) - 32px);
  overflow-y: auto;
  color: var(--navy);
  margin: auto;
}
.auth::backdrop { background: rgba(19, 34, 63, .55); }
.auth h2 { font-family: var(--font-head); font-size: 16px; margin: 0 0 12px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.auth-tab {
  flex: 1; min-height: 44px;
  font-family: var(--font-head); font-size: 10px; text-transform: uppercase;
  background: var(--sand); color: var(--navy);
  border: 3px solid var(--navy); border-radius: 0; cursor: pointer;
}
.auth-tab[aria-selected="true"] { background: var(--orange); box-shadow: 3px 3px 0 var(--navy); }
#auth-form { display: grid; gap: 10px; }
.field { display: grid; gap: 4px; font-size: 20px; }
.field input {
  width: 100%; min-height: 48px;
  font: 22px/1 var(--font-body);
  color: var(--navy); background: var(--white);
  border: 3px solid var(--navy); border-radius: 0;
  padding: 8px 10px;
}
.field input:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.auth-msg { margin: 0; min-height: 1.1em; font-size: 20px; line-height: 1.1; }
.auth-msg.err { color: var(--white); background: var(--coral); padding: 4px 8px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 8px; }
.dayline { font-family: var(--font-head); font-size: 12px; margin: 10px 0 6px; color: var(--water-deep); }
.streakline { margin: 6px 0; }
.countdown { margin: 8px 0 0; color: var(--navy-soft); }
.cd { font-family: var(--font-head); font-size: 12px; color: var(--navy); }

/* ---------- game ---------- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--navy);
  color: var(--white);
  border: var(--px) solid var(--navy);
  box-shadow: 4px 4px 0 rgba(19, 34, 63, .45);
  padding: 6px 10px;
  font-family: var(--font-head);
  font-size: 12px;
}
.dots { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.dots li {
  width: 28px; height: 28px;
  background: var(--navy-soft);
  border: 3px solid var(--white);
  display: grid; place-items: center;
  font-size: 14px; line-height: 1;
}
.dots li.dot-now { background: var(--sun); }
.dots li.dot-miss { background: #000; color: var(--coral); font-size: 10px; }
.dots li[class^="dot-"]:not(.dot-now):not(.dot-miss) { background: var(--white); }
.hdr-score { color: var(--sun); min-width: 3ch; text-align: right; }

.timer-wrap { display: flex; align-items: center; gap: 8px; }
.timer {
  flex: 1;
  display: flex;
  gap: 2px;
  height: 22px;
  padding: 3px;
  background: var(--navy);
  border: 3px solid var(--navy);
  box-shadow: 3px 3px 0 rgba(19, 34, 63, .45);
}
.timer i { flex: 1; background: #24395f; }
.timer i.on { background: var(--palm); box-shadow: inset 0 3px 0 #5fd47f; }
.timer.t-orange i.on { background: var(--orange); box-shadow: inset 0 3px 0 #ffd08a; }
.timer.t-coral i.on { background: var(--coral); box-shadow: inset 0 3px 0 #ffb0a8; }
.timer.t-blink i.on { animation: blink 0.5s steps(1, end) infinite; }
.timer-num {
  font-family: var(--font-head); font-size: 14px;
  background: var(--navy); color: var(--white);
  padding: 4px 6px; min-width: 3.2ch; text-align: center;
}
@keyframes blink { 50% { opacity: 0.15; } }

.clue-card { position: relative; text-align: center; padding: 12px 14px 14px; }
.round-label { margin: 0 0 8px; font-family: var(--font-head); font-size: 10px; color: var(--water-deep); text-transform: uppercase; }
.slots { display: flex; justify-content: center; gap: 6px; margin: 4px 0 10px; }
.slot {
  width: 30px; height: 34px;
  display: grid; place-items: center;
  font-family: var(--font-head); font-size: 14px;
  color: var(--navy-soft);
  border-bottom: 4px solid var(--navy);
}
.slot-known { background: var(--water); color: var(--white); border: 3px solid var(--navy); }
.clue { margin: 0; font-size: 26px; line-height: 1.1; }
.timer-wrap { position: relative; }
/* "Ready… GO!" sits over the timer bar, so it never covers the clue */
.ready {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  margin: 0;
  background: var(--navy);
  font-family: var(--font-head); font-size: 14px;
  color: var(--sun);
  pointer-events: none;
  animation: pop-in .3s steps(3, end);
}
.ready[hidden] { display: none; }
@keyframes pop-in { from { transform: scale(.6); } to { transform: scale(1); } }

.stage { display: flex; flex-direction: column; gap: 10px; }
.stage[hidden] { display: none; }
.entry { position: relative; align-self: center; }
.boxes { display: flex; gap: 8px; }
.box {
  width: var(--box); height: var(--box);
  display: grid; place-items: center;
  background: var(--white);
  border: var(--px) solid var(--navy);
  box-shadow: 3px 3px 0 var(--navy);
  font-family: var(--font-head);
  font-size: calc(var(--box) * 0.42);
  color: var(--navy);
  user-select: none;
}
.box.ghost { color: #c9bfa6; }
.box.filled { background: #e6fbfb; }
.box.bad { background: var(--coral); color: var(--white); }
.entry:focus-within .box.cur { box-shadow: 3px 3px 0 var(--navy), inset 0 -6px 0 var(--water); }
.entry:focus-within .boxes { outline: 3px dashed var(--navy); outline-offset: 5px; }
.guess {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  font-size: 16px; /* avoids iOS zoom-on-focus */
  border: 0; padding: 0;
  caret-color: transparent;
  color: transparent;
  background: transparent;
}
.boxes.shake { animation: shake .4s steps(6, end); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(6px); }
}
.boxes.flash .box { animation: flash .6s steps(2, end) 2; }
@keyframes flash { 50% { background: var(--sun); } }

.feedback {
  margin: 0; min-height: 1.2em; text-align: center;
  font-size: 22px;
  color: var(--navy);
  background: rgba(255, 244, 214, .9);
  align-self: center; padding: 0 8px;
}
.feedback:empty { background: transparent; }
.feedback.err { color: var(--white); background: var(--coral); }
.btn-submit { width: 100%; }

.result-panel { text-align: center; padding: 12px; }
.res-word { margin: 0; font-family: var(--font-head); font-size: 22px; letter-spacing: 2px; }
.res-word.res-miss { color: var(--coral); }
.res-tier { margin: 8px 0 6px; font-family: var(--font-head); font-size: 13px; }
.res-others { margin: 0; color: var(--navy-soft); }
.tier-coconut { color: var(--t-coconut); }
.tier-mango { color: #c76d00; }
.tier-pineapple { color: #9c7a00; }
.tier-starfruit { color: #d93a2b; }
.tier-driftwood { color: var(--t-driftwood); }
.tier-miss { color: var(--navy-soft); }

/* ---------- summary ---------- */
.summary-panel { text-align: center; overflow-y: auto; max-height: 100%; }
.sum-score { font-family: var(--font-head); font-size: 28px; margin: 6px 0; color: var(--navy); text-shadow: 3px 3px 0 var(--sun); }
.sum-title { font-family: var(--font-head); font-size: 12px; margin: 4px 0 10px; color: var(--water-deep); }
.sum-rounds { list-style: none; margin: 0; padding: 0; text-align: left; border-top: 3px solid var(--navy); }
.sum-rounds li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  padding: 4px 2px; border-bottom: 2px dashed var(--sand-dark);
  font-size: 20px; line-height: 1.05;
}
.sr-word { font-family: var(--font-head); font-size: 11px; }
.sr-pts { min-width: 4.2ch; text-align: right; }
.share-msg { margin: 0; min-height: 1em; color: var(--palm-dark); }
.share-fallback { display: grid; gap: 4px; text-align: left; margin-top: 6px; }
.share-fallback[hidden] { display: none; }
.share-fallback textarea {
  font: 18px/1.2 var(--font-body); width: 100%; resize: none;
  border: 3px solid var(--navy); border-radius: 0; background: var(--white); color: var(--navy); padding: 6px;
}

/* ---------- how to play ---------- */
.howto {
  max-width: min(440px, calc(100vw - 32px));
  max-height: calc(var(--vvh) - 32px);
  overflow-y: auto;
  color: var(--navy);
  margin: auto;
}
.howto::backdrop { background: rgba(19, 34, 63, .55); }
.howto h2 { font-family: var(--font-head); font-size: 16px; margin: 0 0 10px; }
.howto p { margin: 8px 0; }
.howto .btn { width: 100%; margin-top: 8px; }
.tier-table { border-collapse: collapse; width: 100%; font-size: 20px; }
.tier-table td { padding: 2px 6px; border-bottom: 2px dashed var(--sand-dark); }
.tier-table td:nth-child(2) { font-family: var(--font-head); font-size: 11px; text-align: right; }

/* ---------- splash fx ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.drop { position: absolute; display: block; box-shadow: 2px 2px 0 rgba(19, 34, 63, .5); }
.sparkle {
  position: absolute; display: block; width: 4px; height: 4px; background: #fff;
  box-shadow: 4px 0 0 var(--sun), -4px 0 0 var(--sun), 0 4px 0 var(--sun), 0 -4px 0 var(--sun);
}
.pop {
  position: absolute;
  font-family: var(--font-head); font-size: 22px;
  text-shadow: 3px 3px 0 var(--navy);
  color: var(--white);
  white-space: nowrap;
}
.pop.tier-starfruit { color: var(--sun); }

/* ---------- small screens & phone keyboard ---------- */
@media (max-height: 700px) {
  :root { --gap: 9px; }
  .panel { padding: 12px; }
  .title { font-size: clamp(18px, 6vw, 24px); margin-bottom: 8px; }
  .btn-col { margin: 10px 0; gap: 12px; }
  .title-accent { margin-top: 6px; }
  .stats { margin-bottom: 10px; }
  .stat { padding: 6px 4px 5px; }
  .stat b { font-size: 16px; }
  .week { margin-bottom: 10px; }
  .wk-box { width: 26px; height: 26px; }
  .wk-name { font-size: 16px; }
  .btn-big { min-height: 50px; }
  .save-note { font-size: 18px; margin-bottom: 8px; }
  .home-foot { margin-top: 10px; font-size: 17px; }
}
html.short { --gap: 6px; }
html.short .round-label { display: none; }
html.short .clue-card { padding: 8px 10px 10px; }
html.short .slots { margin: 0 0 6px; }
html.short .slot { width: 26px; height: 28px; font-size: 12px; }
html.short .clue { font-size: 22px; }
html.short .dots li { width: 24px; height: 24px; }
html.kb-open #app { padding-top: 8px; padding-bottom: 8px; }
html.kb-open .screen { justify-content: flex-start; }
html.kb-open { --box: min(52px, calc((100vw - 32px - 4 * 8px) / 5)); }
html.kb-open .result-panel .res-others { display: none; }

@media (min-width: 700px) {
  .screen { max-width: 480px; }
  .btn { font-size: 14px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .timer.t-blink i.on, .ready, .boxes.shake { animation: none; }
  .boxes.shake .box { background: #ffd0cb; }
}
