/* Coptic Charades on the web: the app's lapis and gold. */

@font-face { font-family: "Irish Grover"; src: url("fonts/IrishGrover-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Nunito"; font-weight: 600; src: url("fonts/nunito-latin-600-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Nunito"; font-weight: 800; src: url("fonts/nunito-latin-800-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Nunito"; font-weight: 900; src: url("fonts/nunito-latin-900-normal.woff2") format("woff2"); font-display: swap; }
@font-face {
  font-family: "Noto Sans Coptic"; src: url("fonts/noto-sans-coptic-coptic-400-normal.woff2") format("woff2");
  unicode-range: U+03E2-03EF, U+2C80-2CFF, U+102E0-102FF; font-display: swap;
}

:root {
  --lapis: #1C2B78;
  --lapis-deep: #131E5A;
  --lapis-night: #0D1545;
  --surface: #2A3B94;
  --raised: #34479F;
  --border: #4558B5;
  --gold: #FBD539;
  --gold-soft: #FFE680;
  --vermilion: #FF7A59;
  --green: #5FD39A;
  --text: #F4F1E8;
  --text-2: #C5CDF3;
  --text-3: #9FAAE6;

  --display: "Irish Grover", "Noto Sans Coptic", "Marker Felt", fantasy;
  --body: "Nunito", ui-rounded, "SF Pro Rounded", "Noto Sans Coptic", system-ui, sans-serif;
  --coptic: "Noto Sans Coptic", "Antinoou", serif;

  --gutter: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--lapis); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--lapis); color: var(--text);
  font-family: var(--body); font-weight: 600; font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: var(--lapis-deep); padding: 8px 14px; border-radius: 10px; font-weight: 800; z-index: 99; }
.skip:focus { left: 8px; }

.display { font-family: var(--display); font-weight: 400; color: var(--gold); line-height: 1.05; }
.muted { color: var(--text-2); }
.kicker { font-size: 13px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-3); }
.label { font-size: 13px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.link-btn { border: 0; background: none; padding: 4px 0; color: var(--gold); font-weight: 800; cursor: pointer; }

.view { min-height: 100vh; min-height: 100dvh; }
.view.centered { display: grid; place-items: center; padding: 24px var(--gutter) calc(24px + var(--safe-b)); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border: 0; border-radius: 999px; cursor: pointer;
  font-family: var(--display); font-size: 21px; line-height: 1; text-decoration: none;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-gold { background: var(--gold); color: var(--lapis-deep); }
.btn-gold:hover:not(:disabled) { background: var(--gold-soft); }
.btn-outline { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--border); }
.btn-outline:hover { box-shadow: inset 0 0 0 2px var(--text-3); }
.btn-surface { background: var(--surface); color: #fff; font-family: var(--body); font-weight: 800; font-size: 15px; }
.btn-small { min-height: 44px; padding: 0 18px; }
.btn-big { width: 100%; min-height: 58px; font-size: 23px; }
.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 22px; background: var(--surface); color: #fff; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.floating { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: 12px; background: rgba(19, 30, 90, 0.7); backdrop-filter: blur(6px); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.actions .btn { flex: 1 1 140px; }

/* Home */
#view-home { max-width: 1100px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top, 0px)) var(--gutter) calc(32px + var(--safe-b)); }
.top { display: flex; align-items: center; gap: 12px; }
.top > div { flex: 1; min-width: 0; }
.back-site { width: 40px; height: 40px; display: grid; place-items: center; color: var(--text-3); border-radius: 20px; flex: none; }
.back-site svg { width: 22px; height: 22px; }
.back-site:hover { color: #fff; background: var(--lapis-deep); }
.wordmark { font-family: var(--display); font-weight: 400; color: var(--gold); font-size: clamp(30px, 7vw, 44px); line-height: 1; }
.tagline { color: var(--text-2); margin-top: 4px; }
#sound-toggle .sound-off, #sound-toggle[aria-pressed="false"] .sound-on { display: none; }
#sound-toggle[aria-pressed="false"] .sound-off { display: block; }

.mode-switch { display: flex; gap: 4px; padding: 4px; margin: 20px 0 8px; background: var(--lapis-deep); border-radius: 16px; max-width: 420px; }
.mode-switch button { flex: 1; min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--text-2); font-weight: 800; cursor: pointer; }
.mode-switch button[aria-checked="true"] { background: var(--gold); color: var(--lapis); }

.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 12px; }
.list-head h2 { font-family: var(--display); font-weight: 400; color: #fff; font-size: 28px; }
.list-head .muted { font-size: 14px; font-weight: 800; color: var(--text-3); }
.status { color: var(--text-2); padding: 24px 0; text-align: center; }
.status .btn { margin-top: 14px; }

.deck-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; }
@media (min-width: 640px) { .deck-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 18px; } }
@media (min-width: 960px) { .deck-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.deck-tile { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.deck-art { display: block; position: relative; width: 100%; aspect-ratio: 465 / 790; border-radius: 16px; overflow: hidden; background: var(--lapis-deep); box-shadow: 0 8px 20px rgba(8, 12, 40, 0.45); transition: transform 0.15s ease; }
.deck-tile:hover .deck-art { transform: translateY(-3px); }
.deck-art img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.deck-art .badge { position: absolute; top: 10px; right: 10px; padding: 3px 9px; border-radius: 9px; background: var(--vermilion); color: var(--lapis-deep); font-size: 12px; font-weight: 900; letter-spacing: 0.8px; }
.deck-name { display: block; margin-top: 10px; font-family: var(--display); color: var(--gold); font-size: 19px; line-height: 1.1; }
.deck-meta { display: block; margin-top: 3px; color: var(--text-3); font-size: 13px; font-weight: 800; }

.get-app { margin-top: 36px; padding: 18px; border-radius: 18px; background: var(--lapis-deep); display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; justify-content: space-between; }
.get-app p { color: var(--text-2); }
.get-app strong { color: #fff; }
.store-links { display: flex; gap: 14px; }
.store-links a { color: var(--gold); font-weight: 800; text-decoration: none; }
.store-links a:hover { text-decoration: underline; }

/* Deck detail */
#view-deck { padding-bottom: calc(110px + var(--safe-b)); }
.deck-hero { position: relative; max-height: 46vh; overflow: hidden; border-bottom: 3px solid var(--gold); background: var(--lapis-deep); }
.deck-hero img { width: 100%; aspect-ratio: 390 / 270; max-height: 46vh; object-fit: cover; object-position: top; }
.deck-body { max-width: 720px; margin: 0 auto; padding: 20px var(--gutter) 0; }
.deck-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.deck-title-row h1 { font-size: clamp(30px, 7vw, 40px); }
.pill { flex: none; margin-top: 6px; padding: 5px 10px; border-radius: 10px; background: var(--lapis-deep); color: var(--text-2); font-size: 13px; font-weight: 800; }
.description { margin-top: 10px; color: var(--text-2); }
.description.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.options { margin-top: 22px; display: grid; gap: 22px; padding: 20px; border-radius: 22px; background: var(--lapis-deep); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-even { flex-wrap: nowrap; }
.chips-even .chip { flex: 1; }
.chip {
  min-height: 46px; padding: 0 14px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--surface); color: #fff; font-weight: 800; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.chip[aria-checked="true"], .chip[aria-pressed="true"] { background: var(--gold); color: var(--lapis-deep); }
.chip svg { width: 16px; height: 16px; stroke-width: 3; }
.tip { color: var(--text-2); font-size: 14px; }
.tip strong { color: #fff; }

.start-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px var(--gutter) calc(12px + var(--safe-b));
  background: rgba(28, 43, 120, 0.97); box-shadow: 0 -10px 24px rgba(8, 12, 40, 0.35);
}
.start-bar > * { max-width: 560px; margin: 0 auto; }

/* Team turn */
.team-card, .ready-card { width: 100%; max-width: 480px; text-align: center; display: grid; gap: 14px; }
.team-card h1, .ready-card h1 { font-size: clamp(38px, 10vw, 54px); }
.board { list-style: none; margin: 6px 0; padding: 6px 0; border-radius: 20px; background: var(--lapis-deep); text-align: left; }
.board li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 52px; }
.board li + li { border-top: 1px solid var(--surface); }
.board .pos { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--surface); font-weight: 900; font-size: 14px; }
.board li.lead .pos { background: var(--gold); color: var(--lapis-deep); }
.board li.current { background: rgba(251, 213, 57, 0.08); }
.board .name { flex: 1; font-weight: 800; }
.board .pts { font-family: var(--display); color: var(--gold); font-size: 24px; }

/* Ready */
.ready-art svg { width: 160px; height: 100px; margin: 0 auto; display: block; stroke-width: 4; }
.ready-art rect { stroke: var(--gold); fill: var(--lapis-deep); }
.ready-art .down { stroke: var(--green); }
.ready-art .up { stroke: var(--vermilion); }
.howto { list-style: none; margin: 0; padding: 14px 16px; display: grid; gap: 12px; border-radius: 18px; background: var(--lapis-deep); text-align: left; }
.howto li { display: flex; align-items: center; gap: 12px; color: var(--text-2); }
.dot { width: 30px; height: 30px; flex: none; display: inline-grid; place-items: center; border-radius: 50%; color: var(--lapis-deep); font-weight: 900; font-size: 16px; line-height: 1; }
.dot.small { width: 22px; height: 22px; font-size: 12px; }
.dot.ok { background: var(--green); }
.dot.pass { background: var(--vermilion); }
.dot.plain { background: var(--surface); color: #fff; }
.dot.none { background: var(--text-3); }

/* Play stage */
.view.play { position: fixed; inset: 0; min-height: 0; background: var(--lapis); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage { position: absolute; inset: 0; display: flex; flex-direction: column; }
.timer-bar { height: 8px; background: var(--lapis-deep); flex: none; }
.timer-bar span { display: block; height: 100%; width: 100%; background: var(--gold); transform-origin: left; transition: transform 0.25s linear, background 0.3s; }
.timer-bar span.low { background: var(--vermilion); }
.play-top { position: relative; z-index: 3; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.play-top > :first-child { justify-self: start; }
.play-top > :last-child { justify-self: end; grid-column: 3; }
.chip-static { padding: 0 12px; height: 32px; display: inline-flex; align-items: center; border-radius: 16px; background: var(--surface); font-weight: 800; font-size: 15px; }
.hud { grid-column: 2; display: flex; align-items: center; gap: 14px; padding: 6px 16px; border-radius: 16px; background: var(--lapis-deep); }
.hud-time { font-family: var(--display); color: var(--gold); font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; min-width: 2.6em; text-align: center; }
.hud-time.low { color: var(--vermilion); }
.hud-sep { width: 2px; height: 22px; background: var(--border); }
.hud-score { display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 18px; }
.hud-score svg { width: 18px; height: 18px; stroke: var(--green); stroke-width: 3.4; }

.countdown, .word-wrap, .times-up { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 70px 130px 20px; pointer-events: none; }
.count-num { font-family: var(--display); color: var(--gold); font-size: min(38vmin, 220px); line-height: 1; animation: pop 0.35s cubic-bezier(.3,1.6,.6,1); }
.count-sub { font-family: var(--display); font-size: clamp(22px, 5vmin, 34px); }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } to { transform: none; opacity: 1; } }
.word-deck { font-size: 13px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word { margin-top: 6px; font-family: var(--display); color: var(--gold); line-height: 1.02; font-size: var(--word-size, 84px); overflow-wrap: anywhere; }
.word.coptic { font-family: var(--coptic); }
.word-meaning { margin-top: 10px; font-size: clamp(18px, 4vmin, 28px); font-weight: 800; color: var(--text-2); }
.times-up { font-family: var(--display); color: var(--gold); font-size: min(16vmin, 120px); }


.flash { position: absolute; inset: 0; z-index: 4; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--lapis-deep); padding: 0 40px; text-align: center; animation: fade 0.12s ease; }
.flash.ok { background: var(--green); }
.flash.pass { background: var(--vermilion); }
.flash-icon { width: 96px; height: 96px; display: grid; place-items: center; border-radius: 50%; background: var(--lapis-deep); }
.flash-icon svg { width: 48px; height: 48px; stroke-width: 3.6; }
.flash.ok .flash-icon { color: var(--green); }
.flash.pass .flash-icon { color: var(--vermilion); }
.flash-title { font-family: var(--display); font-size: min(14vmin, 72px); line-height: 1; }
.flash-word { font-size: clamp(17px, 4vmin, 24px); font-weight: 900; opacity: 0.8; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Results */
#view-results { padding-bottom: calc(100px + var(--safe-b)); }
.results { max-width: 620px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top, 0px)) var(--gutter) 0; text-align: center; }
.results-team { margin-top: 6px; color: #fff; font-size: 26px; }
.score-line { display: flex; align-items: baseline; justify-content: center; gap: 8px; font-weight: 400; margin-top: 6px; }
.score-big { font-family: var(--display); color: var(--gold); font-size: 96px; line-height: 1; }
.score-of { font-family: var(--display); color: var(--text-2); font-size: 28px; }
.cheer { font-family: var(--display); color: var(--vermilion); font-size: 26px; }
.stat-pills { display: flex; justify-content: center; gap: 8px; margin: 14px 0 20px; }
.stat { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 7px; border-radius: 16px; background: var(--lapis-deep); font-weight: 800; font-size: 14px; color: var(--text-2); }
.result-list { list-style: none; margin: 0; padding: 6px 0; border-radius: 20px; background: var(--lapis-deep); text-align: left; }
.result-list li { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 4px 6px 4px 16px; }
.result-list li + li { border-top: 1px solid var(--surface); }
.result-list .w { flex: 1; min-width: 0; font-weight: 800; }
.result-list .w small { display: block; font-size: 13px; color: var(--text-3); font-weight: 700; }
.result-list li.miss .w { color: var(--text-2); }
.result-list .info { width: 44px; height: 44px; flex: none; border: 0; background: none; color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.result-list .info:hover { color: var(--gold); }
.result-list .info svg { width: 22px; height: 22px; }
.result-list .empty { color: var(--text-2); justify-content: center; padding: 20px; }
.coptic-text { font-family: var(--coptic); }

/* Dialogs */
dialog { width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 24px; background: var(--lapis); color: var(--text); box-shadow: 0 20px 50px rgba(8, 12, 40, 0.6); }
dialog::backdrop { background: rgba(13, 21, 69, 0.75); }
.sheet { display: grid; gap: 14px; padding: 24px 20px 20px; }
.sheet h2.display { font-size: 32px; }
.team-names { display: grid; gap: 8px; }
.team-row { display: flex; gap: 8px; }
.team-row input { flex: 1; min-width: 0; min-height: 48px; padding: 0 14px; border-radius: 14px; border: 2px solid var(--border); background: var(--lapis-deep); color: #fff; font: inherit; font-weight: 800; }
.team-row input:focus { border-color: var(--gold); outline: none; }
.team-row .icon-btn { width: 48px; height: 48px; border-radius: 14px; }
.learn-word { font-size: 36px; }
.learn-word.coptic { font-family: var(--coptic); }
.learn-note { color: var(--text); font-size: 17px; line-height: 1.55; }

.toast { position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--lapis-deep); font-weight: 800; box-shadow: 0 10px 24px rgba(8, 12, 40, 0.45); }

@media (max-height: 420px) {
  .countdown, .word-wrap, .times-up { padding: 60px 110px 12px; }
  .hud-time { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Big screen (projector, TV or laptop the room can see) */
.big-controls { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; justify-content: center; gap: 18px; padding: 0 24px max(28px, var(--safe-b)); }
.big-controls .btn { min-height: 72px; min-width: 220px; font-size: 30px; gap: 12px; }
.big-controls svg { width: 30px; height: 30px; stroke-width: 3; }
.big-pass { background: var(--lapis-deep); color: var(--vermilion); box-shadow: inset 0 0 0 3px var(--vermilion); }
.big-pass:hover { background: rgba(255, 122, 89, 0.12); }
.big-ok { background: var(--green); color: var(--lapis-deep); }
.big-ok:hover { background: #7FE0B0; }
.stage.big .countdown, .stage.big .word-wrap { padding: 110px 60px 140px; }
.stage.big .play-top { padding-top: 22px; }
.stage.big .hud { padding: 10px 24px; gap: 20px; border-radius: 22px; }
.stage.big .hud-time { font-size: clamp(36px, 5vw, 64px); }
.stage.big .hud-score { font-size: clamp(22px, 2.6vw, 34px); }
.stage.big .hud-score svg { width: 28px; height: 28px; }
.stage.big .chip-static { height: 48px; padding: 0 20px; font-size: clamp(18px, 2vw, 26px); border-radius: 24px; }
.stage.big .word-deck { font-size: clamp(14px, 1.4vw, 20px); }
.stage.big .count-sub { font-size: clamp(26px, 3.4vw, 48px); }
.stage.big .flash-icon { width: 150px; height: 150px; }
.stage.big .flash-icon svg { width: 76px; height: 76px; }
.stage.big .flash-title { font-size: min(16vmin, 130px); }
.stage.big .flash-word { font-size: clamp(22px, 3vw, 40px); }
.stage.big .timer-bar { height: 12px; }
/* Make the scoreboard and results readable from the back of the room. */
@media (min-width: 1100px) and (min-height: 650px) {
  body.big-screen .team-card, body.big-screen .ready-card { zoom: 1.4; }
  body.big-screen .results { zoom: 1.25; }
}
.stage.big #play-end { min-height: 52px; padding: 0 24px; font-size: 18px; }
.board { overflow: hidden; }
.start-bar > .btn { display: flex; }
@media (min-width: 760px) {
  .deck-hero { max-width: 720px; margin: 24px auto 0; border: 0; border-radius: 22px; box-shadow: 0 10px 28px rgba(8, 12, 40, 0.45); }
  .deck-hero img { aspect-ratio: 16 / 7; max-height: 340px; }
}

/* Phones are pointed to the apps; the web version is for a big screen. */
.phone-note { margin-top: 18px; padding: 16px 18px; border-radius: 18px; background: var(--lapis-deep); box-shadow: inset 0 0 0 2px var(--gold); display: grid; gap: 10px; }
.phone-note p { color: var(--text-2); }
.phone-note strong { color: #fff; }
