:root {
  --ink: #352d21;
  --muted: #7d715f;
  --paper: #eee5d2;
  --card: #fff8e9;
  --line: #d8c8a8;
  --orange: #ad6240;
  --blue: #537f8f;
  --green: #4a6740;
  --display: Georgia, 'Times New Roman', serif;
}

body {
  background-color: var(--paper);
  background-image: radial-gradient(ellipse at 18% 4%, #fff9e788, transparent 34%),
    radial-gradient(ellipse at 88% 72%, #d6c5a622, transparent 42%);
}

.paper-grain { opacity: .28; }
.topbar { border-color: #9b835433; }
.brand { display: inline-flex; align-items: center; gap: 9px; }
.brand-logo { display: block; width: 40px; height: 40px; filter: drop-shadow(0 2px 1px #49351c33); }
.brand .brand-name { color: var(--ink); white-space: nowrap; }
.brand .brand-name > span { color: #82755e; font-weight: 500; }
.hero-copy .eyebrow, .room-head .eyebrow { color: #526b42; }
.hero-copy h1, .room-head h1, .panel-top h2, .section-heading h2,
.order-title h3, .stash-panel h3, .result-panel h2 { text-shadow: 0 1px #fff9e8; }

.lobby-card, .lobby-panel, .order-panel, .stash-panel, .island-panel,
.result-panel, .tutorial-card {
  background: linear-gradient(145deg, #fff9ec, #f8efd9);
  border: 1px solid #d3c19d;
  box-shadow: 0 5px 0 #b6a27c44, 0 16px 36px #59462a12, inset 0 1px #fffdf5;
}
.lobby-card { border-radius: 11px; }
.lobby-panel, .order-panel, .stash-panel, .island-panel { border-radius: 9px; }
.result-panel, .tutorial-card { border-radius: 12px; }

.button, .site-card, .team-select-button, .helper-vote-button,
.team-customize input, .team-customize select {
  border-radius: 5px;
}
.button.primary {
  background: linear-gradient(#607a4b, #405d39);
  box-shadow: 0 3px 0 #2d482c;
}
.button.dark { background: linear-gradient(#594a35, #403523); box-shadow: 0 3px 0 #302719; }
.button:active { box-shadow: none; }

.team-box.ember { background: #f7e5d1; border-color: #dfb895; }
.team-box.tide { background: #e2ece4; border-color: #b6c9b3; }
.team-box.ember .team-box-head { color: #995136; }
.team-box.tide .team-box-head { color: #49694b; }
.player-chip { background: #fff8e9; border: 1px solid #e5d8bd; }
.launch-row, .stash-grid > div { border-color: #ded1b7; }

.score-card { background: linear-gradient(#fff9ec, #f5ecd9); border-color: #d8c8a8; }
.score-card.ember { border-top-color: #b86b43; }
.score-card.tide { border-top-color: #66815a; }
.timer-track { background: #d8c9ab; }
.timer-track i { background: #b86b43; }
.event-banner { background: #e5ead8; border-color: #c5d0b5; color: #455d3c; }
.event-banner span, .launch-tip span { color: #ad6240; }

.order-panel, .stash-panel { box-shadow: 0 3px 0 #b6a27c33, 0 8px 20px #59462a0b; }
.order-title span { background: #efe0bf; border: 1px solid #e1cda7; }
.cost-pill { background: #eee4cf; color: #5b4d38; border: 1px solid #e2d4b8; }
.cost-pill.ready { background: #e2ead8; color: #456541; border-color: #c8d5b7; }
.my-team-pill { color: #8f4c2e; background: #f2dfca; }
.my-team-pill.tide-pill { color: #426848; background: #e0eadc; }
.stash-grid > div { border-right-color: #ded1b7; }

.voyage-map {
  border: 2px solid #d5c49e;
  box-shadow: inset 0 0 0 2px #fff6dc55, 0 3px 0 #b6a27c33;
}
body.light-mode .voyage-map {
  background: radial-gradient(ellipse at 50% 72%, #8fb5a3 0%, #709c91 48%, #547d78 100%);
}
.map-routes .island-shape { fill: #788653; stroke: #c2b77e; }
.map-routes .island-detail { stroke: #e0d39c; opacity: .55; }
.map-routes .region-line { stroke: #e9ddb0; opacity: .72; }
.map-routes .route-line { stroke: #f4d98f; stroke-width: 2.5; opacity: .95; }
.map-node > span { background: #566f49; border-color: #d5cb96; }
.camp-node > span { background: #a5653d; }

.site-card {
  min-height: 158px;
  border-color: #d7c8aa;
  box-shadow: 0 3px 0 #b6a27c44, inset 0 1px #fff;
}
.site-card[data-site="grove"] { background: linear-gradient(150deg, #f2f2df, #e5e7cd); }
.site-card[data-site="quarry"] { background: linear-gradient(150deg, #f3eee2, #e6ddc9); }
.site-card[data-site="crystal"] { background: linear-gradient(150deg, #edf1e7, #dce9df); }
.site-card:hover { border-color: #9a9d6b; box-shadow: 0 4px 0 #a4936844; }
.site-card:disabled { opacity: .62; }
.site-card .gather-cta { color: #4a6740; }
.trip-status { background: #edf0df; border-color: #d1d7bd; }
.trip-progress { background: #d9dfca; }
.trip-progress i { background: #607c4b; }
.puzzle-button { background: #fff8e9; border-color: #dfcfad; color: #4a6740; }
.powerup-card { background: #f8f0dd; border-color: #ddcfb2; }
.powerup-card.selected { background: #e6ecd9; border-color: #8d9e6d; }
.crew-trip-chip { background: #fff8e9; border-color: #dfd2b9; }
.gather-hint, .powerup-head { color: #82755e; }

body:not(.light-mode) {
  --ink: #efe6d2;
  --muted: #b7a98d;
  --paper: #211f18;
  --card: #302b20;
  --line: #554a35;
  --green: #91a96d;
  --orange: #d28a58;
  --blue: #82a69d;
  background-color: #211f18;
  background-image: radial-gradient(ellipse at 18% 0%, #46503955, transparent 38%),
    radial-gradient(ellipse at 85% 70%, #68452d22, transparent 45%);
  color: var(--ink);
}
body:not(.light-mode) .paper-grain { opacity: .13; }
body:not(.light-mode) .topbar { border-color: #c6b18122; }
body:not(.light-mode) .brand,
body:not(.light-mode) .brand .brand-name { color: #f1e8d6; }
body:not(.light-mode) .brand .brand-name > span,
body:not(.light-mode) .top-note,
body:not(.light-mode) .eyebrow { color: #b9ad92; }
body:not(.light-mode) .hero-copy .eyebrow,
body:not(.light-mode) .room-head .eyebrow { color: #a9bd83; }
body:not(.light-mode) .hero-copy h1 em { color: #aabe8a; }
body:not(.light-mode) .hero-copy > p,
body:not(.light-mode) .panel-top p,
body:not(.light-mode) .launch-tip { color: #c1b69f; }
body:not(.light-mode) .lobby-card,
body:not(.light-mode) .lobby-panel,
body:not(.light-mode) .order-panel,
body:not(.light-mode) .stash-panel,
body:not(.light-mode) .island-panel,
body:not(.light-mode) .result-panel,
body:not(.light-mode) .tutorial-card {
  background: linear-gradient(145deg, #302b20, #29251c);
  border-color: #5c4e36;
  box-shadow: 0 5px 0 #120f0b66, 0 16px 36px #0004, inset 0 1px #75634755;
}
body:not(.light-mode) .lobby-card label,
body:not(.light-mode) .lobby-card .eyebrow { color: #c0b394; }
body:not(.light-mode) .lobby-card input,
body:not(.light-mode) .join-row input,
body:not(.light-mode) .team-customize input,
body:not(.light-mode) .team-customize select {
  background: #211f18;
  border-color: #5c4e36;
  color: #f1e8d6;
}
body:not(.light-mode) .button.primary { background: linear-gradient(#708852, #526c43); box-shadow: 0 3px 0 #34452e; }
body:not(.light-mode) .button.dark { background: linear-gradient(#69563a, #4e402b); box-shadow: 0 3px 0 #342a1c; }
body:not(.light-mode) .team-box.ember { background: #3c2b20; border-color: #6f4d32; }
body:not(.light-mode) .team-box.tide { background: #293329; border-color: #4e6244; }
body:not(.light-mode) .team-box.ember .team-box-head { color: #e39b6d; }
body:not(.light-mode) .team-box.tide .team-box-head { color: #aec395; }
body:not(.light-mode) .player-chip { background: #302b20; border-color: #574a36; color: #e8dfcb; }
body:not(.light-mode) .launch-row,
body:not(.light-mode) .stash-grid > div,
body:not(.light-mode) .order-footer,
body:not(.light-mode) .powerup-head { border-color: #514630; }
body:not(.light-mode) .score-card { background: linear-gradient(#342e22, #2b271e); border-color: #554a35; }
body:not(.light-mode) .event-banner { background: #343a29; border-color: #596044; color: #d1d9b7; }
body:not(.light-mode) .order-title span { background: #453923; border-color: #665438; }
body:not(.light-mode) .cost-pill { background: #423a2b; color: #e0d4ba; border-color: #5d4f38; }
body:not(.light-mode) .cost-pill.ready { background: #35412d; color: #c5d6aa; border-color: #586746; }
body:not(.light-mode) .my-team-pill { color: #edb18a; background: #493124; }
body:not(.light-mode) .my-team-pill.tide-pill { color: #bed0a5; background: #34402d; }
body:not(.light-mode) .site-card,
body:not(.light-mode) .site-card[data-site="grove"],
body:not(.light-mode) .site-card[data-site="quarry"],
body:not(.light-mode) .site-card[data-site="crystal"] {
  background: linear-gradient(150deg, #393728, #302d22);
  border-color: #5b513a;
  box-shadow: 0 3px 0 #17140f88, inset 0 1px #74684b55;
  color: #efe6d2;
}
body:not(.light-mode) .site-card:hover { background: #403d2e; border-color: #89906a; }
body:not(.light-mode) .site-card .gather-cta { color: #b3c58e; }
body:not(.light-mode) .trip-status { background: #303426; border-color: #4e5739; }
body:not(.light-mode) .trip-progress { background: #494a37; }
body:not(.light-mode) .puzzle-button { background: #383a2b; border-color: #596044; color: #c5d5a7; }
body:not(.light-mode) .powerup-card,
body:not(.light-mode) .crew-trip-chip { background: #343025; border-color: #554a35; color: #e8dfcb; }
body:not(.light-mode) .powerup-card.selected { background: #38402c; border-color: #718154; }
body:not(.light-mode) .result-scores div { background: #383225; }
body:not(.light-mode) .helper-panel { background: #303426; border-color: #4e5739; }

@media (max-width: 700px) {
  .site-card { min-height: 145px; }
  .room-head h1 { font-size: 34px; }
  .room-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .room-head-actions { width: 100%; align-items: center; justify-content: space-between; }
  .room-code-box { align-items: flex-start; }
}

.watch-scoreboard-button {
  width: 100%; margin-top: 12px; padding: 8px 2px; border: 0; background: transparent;
  color: #536d45; font: 700 11px var(--sans); text-align: center; cursor: pointer;
}
.watch-scoreboard-button span { margin-left: 5px; font-size: 14px; }
.watch-scoreboard-button:hover { color: #9d5938; }
.room-head-actions { display: flex; align-items: flex-end; gap: 18px; }
.room-head-actions .board-link { min-height: 36px; padding: 0 12px; font-size: 10px; }
.board-link { border: 1px solid #b9a77f; background: #f4ead4; color: #4e5839; box-shadow: 0 2px 0 #b6a27c55; }
.board-link:hover { background: #fff5df; }

.spectator-mode { min-height: 100vh; background: #19241d; }
.spectator-mode .topbar { display: none; }
.spectator-mode #app { width: 100%; max-width: none; padding: 0; }
.spectator-mode .room-view { width: 100%; max-width: none; margin: 0; padding: 0; }
.spectator-screen {
  min-height: 100vh; display: flex; flex-direction: column; gap: clamp(14px, 2vh, 24px);
  padding: clamp(18px, 3.3vw, 48px); overflow: auto; color: #f1e8d6;
  background: radial-gradient(ellipse at 50% 0%, #354a37, transparent 60%), linear-gradient(145deg, #1e2b21, #172019 72%);
}
.tv-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.tv-header .eyebrow { color: #c1bd93; }
.tv-header h2 { margin: 5px 0 0; font: 600 clamp(24px, 3vw, 40px) var(--display); color: #f4ead4; }
.tv-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.tv-actions .board-link { min-height: 38px; }
.tv-phase { padding: 8px 12px; border: 1px solid #708052; border-radius: 30px; background: #35452d; color: #d6dfb8; font-size: 10px; font-weight: 800; letter-spacing: 1px; }
.tv-event { padding: 12px 16px; border: 1px solid #6b7048; border-radius: 8px; background: #343b2a; color: #ede1bb; font-size: clamp(12px, 1.2vw, 16px); font-weight: 600; text-align: center; }
.tv-score-stage { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, 18%) minmax(0, 1fr); align-items: stretch; gap: clamp(12px, 2vw, 28px); }
.tv-team { display: flex; flex-direction: column; min-width: 0; padding: clamp(16px, 2.4vw, 34px); border: 2px solid #ad8a57; border-radius: 12px; background: linear-gradient(145deg, #f3e8cc, #dfcfaa); color: #372e20; box-shadow: 0 5px 0 #0e171166, inset 0 1px #fff9e8; }
.tv-team.tide { border-color: #849b78; background: linear-gradient(145deg, #e8edd9, #d2dfc3); }
.tv-team-head { display: flex; align-items: center; gap: 12px; min-width: 0; padding-bottom: 12px; border-bottom: 1px solid #7c68473b; }
.tv-symbol { font-size: clamp(30px, 4vw, 54px); }
.tv-team-head small { color: #756448; font-size: 9px; font-weight: 800; letter-spacing: 1.5px; }
.tv-team-head h3 { overflow: hidden; margin: 2px 0 0; font: 600 clamp(17px, 2vw, 27px) var(--display); text-overflow: ellipsis; white-space: nowrap; }
.tv-score { display: flex; flex-direction: column; align-items: center; padding: clamp(10px, 2vh, 24px) 0; }
.tv-score b { font: 700 clamp(68px, 10vw, 148px)/.9 var(--display); letter-spacing: -.06em; }
.tv-score span { margin-top: 7px; color: #756448; font-size: 10px; font-weight: 800; letter-spacing: 2px; }
.tv-order { padding: 12px 0; border-top: 1px solid #7c68473b; }
.tv-order-head { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.tv-order-head span { grid-column: 1/-1; color: #756448; font-size: 8px; font-weight: 800; letter-spacing: 1.3px; }
.tv-order-head b { overflow: hidden; font: 600 clamp(14px, 1.6vw, 20px) var(--display); text-overflow: ellipsis; white-space: nowrap; }
.tv-order-head small { color: #6d593c; font-size: 11px; font-weight: 800; }
.tv-costs { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.tv-cost { display: inline-flex; align-items: center; gap: 5px; padding: 7px 9px; border: 1px solid #99835c55; border-radius: 5px; background: #f8efd9; font-size: clamp(11px, 1.2vw, 15px); }
.tv-cost b { font: 700 15px var(--display); }
.tv-cost i { color: #796b55; font-size: 10px; font-style: normal; }
.tv-cost.ready { border-color: #778969; background: #dce7d2; color: #3c5c39; }
.tv-stash { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 0; border-top: 1px solid #7c68473b; border-bottom: 1px solid #7c68473b; }
.tv-stash > span { width: 100%; color: #756448; font-size: 8px; font-weight: 800; letter-spacing: 1.2px; }
.tv-stash b { font: 700 clamp(13px, 1.3vw, 17px) var(--display); }
.tv-players { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; }
.tv-player { display: flex; flex-direction: column; gap: 2px; max-width: 100%; padding: 6px 9px; border-radius: 5px; background: #fff8e8b0; }
.tv-player b { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.tv-player small { overflow: hidden; color: #786c56; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.tv-player.empty { color: #786c56; font-size: 10px; }
.tv-clock { align-self: center; display: flex; flex-direction: column; align-items: center; text-align: center; }
.tv-clock > small { color: #bec69a; font-size: 9px; font-weight: 800; letter-spacing: 1.5px; }
.tv-clock > b { margin: 5px 0; color: #f8edcf; font: 600 clamp(30px, 4vw, 54px) var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tv-clock-track { width: 100%; height: 5px; overflow: hidden; border-radius: 4px; background: #526043; }
.tv-clock-track i { display: block; width: 0; height: 100%; background: #d59b5e; transition: width .5s linear; }
.tv-center-status { max-width: 190px; margin-top: 12px; color: #d4d2ad; font-size: 11px; line-height: 1.5; }
.tv-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 26px; color: #b8bd9f; font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.tv-footer span:nth-child(2) { overflow: hidden; font-size: 10px; font-weight: 500; letter-spacing: 0; text-overflow: ellipsis; white-space: nowrap; }
.tv-footer span:last-child { white-space: nowrap; }
.spectator-screen:fullscreen { min-height: 100vh; border-radius: 0; }
body:not(.light-mode) .watch-scoreboard-button { color: #b6c98e; }
body:not(.light-mode) .watch-scoreboard-button:hover { color: #e0ad7d; }
body:not(.light-mode) .board-link { background: #3b392b; border-color: #6b6445; color: #e9dfc6; }
body:not(.light-mode) .board-link:hover { background: #4a4735; }

@media (max-width: 760px) {
  .room-head-actions { gap: 9px; }
  .room-head-actions .board-link { padding: 0 9px; font-size: 9px; }
  .tv-score-stage { grid-template-columns: 1fr; }
  .tv-clock { order: -1; padding: 5px 0; }
  .tv-clock-track { max-width: 340px; }
  .tv-team { padding: 18px; }
  .tv-score { padding: 10px 0; }
  .tv-score b { font-size: clamp(66px, 19vw, 100px); }
}
@media (max-width: 480px) {
  .tv-header { align-items: flex-start; flex-direction: column; gap: 12px; }
  .tv-actions { justify-content: flex-start; }
  .tv-footer { align-items: flex-start; flex-direction: column; }
  .tv-footer span:nth-child(2) { white-space: normal; }
}
