/* ================================================================ tokens */
:root {
  --brand: #033c72;
  --brand-2: #1d4e7d;
  --ink: #0f2940;
  --muted: #5b6b7c;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-border: rgba(255, 255, 255, 0.9);
  --shadow: 0 6px 20px rgba(10, 30, 60, 0.12);

  --red: #c62f2f;
  --red-dark: #9e1f1f;
  --red-soft: #f4c4bd;
  --blue: #1f6fb2;
  --blue-dark: #15528a;
  --blue-soft: #bfdaf2;
  --neutral: #cbbd9e;
  --neutral-soft: #ece0c6;
  --assassin: #262626;

  --card: #f6e7cf;
  --card-edge: #d2b98f;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Poppins', 'Segoe UI', Tahoma, sans-serif;
  color: var(--ink);
  background: #e9eef3;
  position: relative;
}

/* Background image + frosted overlay, fixed so it never stretches the page. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.55)),
    url('/static/images/background.jpg') center / cover no-repeat;
  filter: blur(3px);
  transform: scale(1.03);
}

[hidden] { display: none !important; }

.t-red { color: var(--red); }
.t-blue { color: var(--blue); }
.t-brand { color: var(--brand); }

/* ================================================================ buttons & inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .2s, transform .15s, box-shadow .2s, opacity .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .card:focus-visible, .code-chip:focus-visible { outline: 3px solid #f5b400; outline-offset: 2px; }

.btn-primary { background: var(--brand-2); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2a649c; }
.btn-dark { background: #2c3e50; color: #fff; }
.btn-dark:hover:not(:disabled) { background: #3d566e; }
.btn-light { background: rgba(255, 255, 255, .9); color: var(--ink); border-color: #cfd8e2; }
.btn-light:hover:not(:disabled) { background: #fff; box-shadow: var(--shadow); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-dark); }
.btn-lg { padding: 13px 28px; font-size: 17px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.icon-btn { padding: 8px 11px; }

input[type=text], select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid #b9c4cf;
  background: #fff;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--ink);
}
input[type=text]:focus, select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(29, 78, 125, .2); }

label { display: block; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.hint { margin: 0; font-size: 14px; color: var(--muted); }

/* ================================================================ home */
.home-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 16px 40px;
  text-align: center;
}
.basmala {
  font-family: 'Reem Kufi', serif;
  font-size: clamp(22px, 5vw, 30px);
  color: var(--brand);
  margin: 0 0 6px;
  text-shadow: 0 0 20px rgb(133, 245, 255), 0 0 30px rgba(0, 44, 138, .6);
}
.intro {
  font-family: 'Reem Kufi', 'Poppins', sans-serif;
  color: var(--brand);
  font-size: clamp(40px, 10vw, 64px);
  margin: 0;
  letter-spacing: .02em;
  text-shadow: 0 0 20px rgb(133, 245, 255), 0 0 30px rgba(0, 44, 138, .6);
}
.tagline { margin: 4px 0 24px; color: var(--ink); font-weight: 500; }

.alert {
  background: #fff4e5;
  border: 1px solid #f3c48b;
  color: #7a4a00;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0 auto 18px;
  max-width: 620px;
}

.form-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.home-card { padding: 22px; text-align: left; display: flex; flex-direction: column; }
.home-card h2 { margin: 0 0 4px; font-size: 20px; color: var(--brand); }
.home-card .btn { margin-top: auto; width: 100%; }
.home-card input { margin-bottom: 16px; }
.code-input { text-transform: uppercase; letter-spacing: .15em; font-weight: 700; }

.rules { margin-top: 20px; padding: 14px 20px; text-align: left; }
.rules summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.rules ol { padding-left: 20px; margin: 10px 0 0; line-height: 1.6; font-size: 15px; }

/* ================================================================ room: top bar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, .9);
  box-shadow: 0 2px 12px rgba(10, 30, 60, .08);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-family: 'Reem Kufi', 'Poppins', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--brand);
  text-decoration: none;
}
.share { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  border-radius: 10px;
  border: 2px dashed var(--brand-2);
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  user-select: all;
  transition: background-color .2s, border-color .2s;
}
.code-chip:hover { background: #eef5fc; }
.code-chip.copied { border-style: solid; border-color: #1e9e5a; background: #e9f8ef; }
.code-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.code-value { font-size: 20px; font-weight: 800; letter-spacing: .14em; color: var(--brand); }
.code-hint {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--brand-2);
  color: #fff;
}
.code-chip.copied .code-hint { background: #1e9e5a; }

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 18px;
  padding: 6px 12px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #cfd8e2;
}
.score-sep { color: var(--muted); }
#meName { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

/* ================================================================ room: layout */
.layout {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(0, 1fr) minmax(190px, 250px);
  grid-template-areas:
    "red main blue"
    "red main side";
  grid-template-rows: auto 1fr;
  gap: 16px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  align-items: start;
}
#panelRed { grid-area: red; }
#panelBlue { grid-area: blue; }
.main { grid-area: main; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.side-panel { grid-area: side; }

/* ================================================================ team panels */
.team-panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-top: 6px solid;
  padding: 12px 14px 14px;
  transition: box-shadow .3s, transform .3s;
}
.team-panel[data-team=Red] { border-color: var(--red); }
.team-panel[data-team=Blue] { border-color: var(--blue); }
.team-panel[data-team=Red].active { box-shadow: 0 0 0 3px var(--red), 0 8px 28px rgba(198, 47, 47, .35); }
.team-panel[data-team=Blue].active { box-shadow: 0 0 0 3px var(--blue), 0 8px 28px rgba(31, 111, 178, .35); }

.team-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.team-head h2 { margin: 0; font-size: 18px; }
.team-panel[data-team=Red] h2 { color: var(--red); }
.team-panel[data-team=Blue] h2 { color: var(--blue); }
.cards-left {
  min-width: 48px;
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 10px;
  color: #fff;
}
.team-panel[data-team=Red] .cards-left { background: var(--red); }
.team-panel[data-team=Blue] .cards-left { background: var(--blue); }

.role-group h4, .side-section h4 {
  margin: 14px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid #d7dee6;
  padding-bottom: 4px;
  text-align: left;
}
.team-panel ul, .player-list { list-style: none; padding: 0; margin: 0 0 8px; }
.team-panel li, .player-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  padding: 3px 0;
  text-align: left;
  min-width: 0;
}
li.you .pname { font-weight: 700; }
li.offline { opacity: .55; }
li.empty { color: #98a4b0; font-style: italic; }
.pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #9aa5b1; }
.dot.online { background: #2ecc71; }
.badge {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f5b400;
  color: #3a2a00;
}
.you-badge { background: #dbe7f3; color: var(--brand-2); }
.join-btn { width: 100%; font-size: 13px; padding: 8px 10px; }

/* ================================================================ side panel */
.side-panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 14px 14px;
}
.side-section .btn { width: 100%; }
.log {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 320px;
  overflow-y: auto;
  font-size: 13px;
  text-align: left;
}
.log li { display: flex; gap: 6px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid #eef1f4; }
.log li.empty { color: #98a4b0; font-style: italic; border: 0; }
.log li.log-clue { font-weight: 700; }
.log li.log-clue.red, .log li.log-system.red { color: var(--red); }
.log li.log-clue.blue, .log li.log-system.blue { color: var(--blue); }
.log li.log-timeout { color: #b26b00; }
.log li.log-system { font-weight: 700; }
.log-dot { flex: none; width: 10px; height: 10px; border-radius: 3px; transform: translateY(1px); }
.log-dot.k-red { background: var(--red); }
.log-dot.k-blue { background: var(--blue); }
.log-dot.k-neutral { background: var(--neutral); }
.log-dot.k-assassin { background: var(--assassin); }

/* ================================================================ status & clue */
.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: #fff;
  background: #2c3e50;
  box-shadow: var(--shadow);
  transition: background-color .4s;
}
.status.red { background: linear-gradient(135deg, var(--red), var(--red-dark)); }
.status.blue { background: linear-gradient(135deg, var(--blue), var(--blue-dark)); }
.status.lobby { background: linear-gradient(135deg, var(--brand-2), var(--brand)); }
.status-text { font-size: 18px; font-weight: 700; text-align: left; }

.timer { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; min-width: 80px; }
.timer-text { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.timer-bar { width: 80px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .3); overflow: hidden; }
.timer-bar i { display: block; height: 100%; background: #fff; transition: width .2s linear; }
.timer.urgent .timer-text { color: #ffe066; animation: pulse 1s ease-in-out infinite; }
.timer.urgent .timer-bar i { background: #ffe066; }
@keyframes pulse { 50% { transform: scale(1.15); } }

.clue-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 16px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 3px solid #2c3e50;
}
.clue-banner.red { border-color: var(--red); }
.clue-banner.blue { border-color: var(--blue); }
.clue-banner.pop { animation: pop .45s ease; }
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 70% { transform: scale(1.04); opacity: 1; } 100% { transform: scale(1); } }
.clue-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.clue-word { font-size: 26px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; overflow-wrap: anywhere; }
.clue-number {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 800;
  background: #2c3e50;
  color: #fff;
}
.clue-banner.red .clue-number { background: var(--red); }
.clue-banner.blue .clue-number { background: var(--blue); }
.clue-guesses { font-size: 14px; color: var(--muted); }

/* ================================================================ board */
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  margin: 0 auto;
  perspective: 900px;
}

.card {
  position: relative;
  aspect-ratio: 1.55;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbf1e1, var(--card));
  box-shadow: 0 3px 0 var(--card-edge), 0 6px 14px rgba(40, 30, 10, .15);
  text-align: center;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .18s, box-shadow .18s, filter .2s;
}
.card .word {
  display: block;
  max-width: 100%;
  padding: .25em .5em;
  border-radius: 7px;
  background: rgba(255, 255, 255, .85);
  font-weight: 700;
  font-size: clamp(11px, 1.25vw, 18px);
  line-height: 1.15;
  overflow-wrap: break-word;
  hyphens: auto;
  color: #2a2014;
}
.card .word.xlong { font-size: clamp(10px, 1.05vw, 15px); }
.card .meaning {
  display: block;
  font-size: clamp(9px, .8vw, 12px);
  line-height: 1.25;
  color: inherit;
  opacity: .85;
  max-height: 2.6em;
  overflow: hidden;
}

/* Key colours (spymaster view, or once the game ends) */
.card.k-red { background: linear-gradient(180deg, #f6cfc9, var(--red-soft)); box-shadow: 0 3px 0 #d98d82, 0 6px 14px rgba(120, 20, 20, .15); color: var(--red-dark); }
.card.k-blue { background: linear-gradient(180deg, #d6e8f7, var(--blue-soft)); box-shadow: 0 3px 0 #85b2d9, 0 6px 14px rgba(10, 50, 100, .15); color: var(--blue-dark); }
.card.k-neutral { background: linear-gradient(180deg, #f5ecda, var(--neutral-soft)); color: #6d5f43; }
.card.k-assassin { background: linear-gradient(180deg, #5a5a5a, #3a3a3a); box-shadow: 0 3px 0 #111, 0 6px 14px rgba(0, 0, 0, .3); color: #eee; }
.card.k-assassin .word { background: rgba(0, 0, 0, .45); color: #fff; }

/* Revealed cards: solid team colour */
.card.revealed { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25), 0 2px 6px rgba(0, 0, 0, .15); }
.card.revealed .word { background: rgba(255, 255, 255, .22); color: inherit; }
.card.revealed.k-red { background: linear-gradient(160deg, #d64545, var(--red-dark)); color: #fff; }
.card.revealed.k-blue { background: linear-gradient(160deg, #2f86cc, var(--blue-dark)); color: #fff; }
.card.revealed.k-neutral { background: linear-gradient(160deg, #d8c9a8, #b9a882); color: #3d3322; }
.card.revealed.k-assassin { background: radial-gradient(circle at 50% 40%, #444, #000); color: #fff; }
.card.revealed.k-assassin::after { content: "☠"; position: absolute; top: 4px; right: 8px; font-size: 16px; opacity: .8; }

/* Spymasters: dim the cards that are already covered so the rest stand out */
.is-spymaster .board:not(.over) .card.revealed { opacity: .4; filter: saturate(.6); }
/* After the game, unrevealed cards are shown faded so you can tell what was guessed */
.board.over .card:not(.revealed) { opacity: .7; }

.card.flip { animation: flip .55s ease; }
@keyframes flip {
  0% { transform: rotateY(90deg) scale(.95); }
  100% { transform: rotateY(0) scale(1); }
}

/* Guessing interactions */
.board.guessing .card.clickable { cursor: pointer; }
@media (hover: hover) {
  .board.guessing .card.clickable:hover { transform: translateY(-3px); box-shadow: 0 6px 0 var(--card-edge), 0 10px 18px rgba(40, 30, 10, .2); }
}
.card.marked { outline: 3px solid #f5b400; outline-offset: -3px; }
.marks {
  position: absolute;
  left: 4px;
  top: 4px;
  right: 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  pointer-events: none;
}
.mark {
  max-width: 100%;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  background: #f5b400;
  color: #3a2a00;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mark-count {
  display: none;
  position: absolute;
  left: 3px;
  top: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #f5b400;
  color: #3a2a00;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
}
.reveal-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #1e9e5a;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  animation: pop .25s ease;
}
.reveal-btn:hover { background: #157a44; transform: scale(1.1); }

/* ================================================================ actions */
.actions:empty { display: none; }
.action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 16px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.clue-form input { flex: 1 1 200px; max-width: 320px; }
.clue-form select { width: auto; min-width: 70px; }

/* ================================================================ modals, toast, banners */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 20, 35, .55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  width: min(100%, 400px);
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  animation: pop .3s ease;
}
.modal-card h2 { margin: 0 0 4px; color: var(--ink); }
.modal-card label { margin-top: 6px; }
.modal-card .btn { width: 100%; margin-top: 6px; }
.over-emoji { font-size: 56px; line-height: 1; }
.over-card h2 { font-size: 28px; }
.over-card h2.t-red { color: var(--red); }
.over-card h2.t-blue { color: var(--blue); }
.over-card p { margin: 0 0 8px; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #1f2d3a;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 200;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.conn-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  padding: 8px;
  text-align: center;
  font-weight: 700;
  background: #f5b400;
  color: #3a2a00;
}

/* ================================================================ responsive */

/* Tablets & small laptops: board on top, teams side by side underneath */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "main main"
      "red blue"
      "side side";
    grid-template-rows: auto;
  }
  .card .word { font-size: clamp(11px, 2vw, 18px); }
  .card .meaning { font-size: clamp(9px, 1.3vw, 12px); }
}

/* Phones */
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 8px 12px; }
  .brand { font-size: 20px; }
  .share { order: 3; width: 100%; }
  .share .code-chip { flex: 1; justify-content: center; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { padding: 7px 10px; font-size: 13px; }
  .donate { display: none; }
  #meName { max-width: 80px; }
  .score-pill { font-size: 15px; padding: 5px 9px; }
  .code-value { font-size: 18px; }

  .layout { padding: 10px; gap: 10px; }
  .main { gap: 8px; }
  .status { padding: 10px 12px; }
  .status-text { font-size: 15px; }
  .timer-text { font-size: 18px; }
  .timer-bar { width: 60px; }
  .clue-banner { padding: 8px 12px; }
  .clue-word { font-size: 20px; }
  .clue-number { min-width: 32px; height: 32px; font-size: 17px; }

  .board { gap: 5px; }
  .card { aspect-ratio: 1.15; padding: 4px 2px; border-radius: 8px; }
  .card .word { font-size: clamp(9px, 2.9vw, 14px); padding: .2em .25em; border-radius: 5px; }
  .card .word.long { font-size: clamp(8px, 2.4vw, 12px); }
  .card .word.xlong { font-size: clamp(7px, 2.1vw, 11px); }
  .card .meaning { display: none; }
  .marks { display: none; }
  .mark-count { display: block; }
  .reveal-btn { width: 26px; height: 26px; font-size: 14px; top: 2px; right: 2px; }

  .team-panel { padding: 10px; }
  .team-head h2 { font-size: 15px; }
  .cards-left { font-size: 22px; min-width: 38px; }
  .team-panel li { font-size: 13px; }
  .join-btn { font-size: 12px; padding: 7px 6px; white-space: normal; }

  .action-row { padding: 10px 12px; }
  .clue-form input { flex-basis: 140px; }
  .clue-form .btn { flex: 1 1 100%; }
}

/* Phones held sideways: keep the board within the screen height */
@media (orientation: landscape) and (max-height: 560px) {
  .topbar { position: static; flex-wrap: nowrap; padding: 6px 12px; gap: 8px; }
  .brand { font-size: 18px; }
  .code-value { font-size: 16px; }
  .topbar .btn { padding: 6px 9px; font-size: 13px; }
  .share .btn span, .donate { display: none; }
  #meName { max-width: 90px; }
  .score-pill { font-size: 14px; padding: 4px 8px; }
  .marks { display: none; }
  .mark-count { display: block; }
  .card .word.long { font-size: clamp(8px, 1.3vw, 12px); }
  .card .word.xlong { font-size: clamp(7px, 1.1vw, 11px); }
  .layout {
    grid-template-columns: minmax(130px, 170px) minmax(0, 1fr) minmax(130px, 170px);
    grid-template-areas:
      "red main blue"
      "side side side";
    padding: 8px;
    gap: 8px;
  }
  .board { max-width: calc((100vh - 70px) * 1.55); gap: 4px; }
  .card { aspect-ratio: 1.55; padding: 2px; border-radius: 7px; }
  .card .word { font-size: clamp(9px, 1.5vw, 13px); }
  .card .meaning { display: none; }
  .status { padding: 6px 10px; }
  .status-text { font-size: 14px; }
  .clue-banner { padding: 4px 10px; }
  .clue-word { font-size: 18px; }
  .team-panel { padding: 8px; }
  .team-head h2 { font-size: 14px; }
  .cards-left { font-size: 20px; min-width: 34px; padding: 4px 6px; }
  .team-panel li { font-size: 12px; }
  .role-group h4 { margin-top: 8px; }
  .join-btn { font-size: 11px; padding: 6px; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
