:root {
  --bg: #0d1e24;
  --bg2: #12303a;
  --panel: rgba(255, 248, 224, 0.93);
  --panel2: rgba(255, 255, 255, 0.88);
  --ink: #17252a;
  --muted: #5e6d70;
  --accent: #e39d34;
  --accent2: #2c8f7b;
  --danger: #b83f32;
  --danger2: #6e1c19;
  --good: #2f8f48;
  --card: #fff9e8;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 5%, rgba(241, 190, 91, 0.45), transparent 24rem),
    radial-gradient(circle at 80% 10%, rgba(75, 184, 179, 0.35), transparent 24rem),
    linear-gradient(160deg, var(--bg), var(--bg2) 48%, #0b151a);
  overflow-x: hidden;
}

body:before {
  content: "";
  position: fixed;
  inset: auto -10% 0 -10%;
  height: 28vh;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 100%, rgba(233, 195, 109, 0.8), transparent 55%),
    radial-gradient(ellipse at 78% 100%, rgba(233, 195, 109, 0.65), transparent 48%),
    linear-gradient(180deg, transparent, rgba(236, 185, 93, 0.55));
  filter: blur(2px);
}

body.dark-mode {
  --bg: #05090d;
  --bg2: #101820;
  --panel: rgba(20, 27, 33, 0.96);
  --panel2: rgba(27, 37, 44, 0.94);
  --ink: #eef6f4;
  --muted: #b8c7c9;
  --card: #1f2b31;
  --accent: #f3a73b;
  --accent2: #68c9ba;
}

body.dark-mode .intro,
body.dark-mode .top-stats,
body.dark-mode .card .desc,
body.dark-mode .radio-stage span,
body.dark-mode .zone-heading p {
  color: var(--muted);
}

body.dark-mode button {
  color: var(--ink);
  background: #2b3b42;
}

body.dark-mode button.primary {
  color: #221506;
}

body.dark-mode button.ghost {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.18);
}

body.dark-mode .card,
body.dark-mode .player-pill,
body.dark-mode .radio-stage,
body.dark-mode .rule-card,
body.dark-mode .log-entry,
body.dark-mode .deck-visual,
body.dark-mode .hint-box {
  color: var(--ink);
}

button, select, input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 0.72rem 0.9rem;
  color: var(--ink);
  background: #f3dfb4;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.08s ease, filter 0.12s ease, opacity 0.12s ease;
}

button:hover:not(:disabled) { filter: brightness(1.04); }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.16); }
button:disabled { opacity: 0.48; cursor: not-allowed; }

button.primary {
  background: linear-gradient(180deg, #f8bb57, var(--accent));
  color: #231607;
  font-weight: 800;
}

button.ghost {
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(20, 40, 44, 0.18);
  box-shadow: none;
}

button.small { padding: 0.45rem 0.65rem; font-size: 0.85rem; }
button.tiny { padding: 0.25rem 0.45rem; font-size: 0.75rem; border-radius: 8px; }
button.full { width: 100%; }

.screen {
  position: relative;
  z-index: 1;
  display: none;
  min-height: 100vh;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.screen.active { display: block; }

.hero-card, .panel {
  max-width: 980px;
  margin: 5vh auto;
  padding: clamp(1.2rem, 4vw, 2.2rem);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.panel.wide { max-width: 1120px; }

.kicker {
  color: var(--accent2);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(3rem, 9vw, 6rem); margin-bottom: 0.2rem; line-height: 0.9; }
h2 { font-size: clamp(1.45rem, 3vw, 2.2rem); margin-bottom: 0.5rem; }
h3 { margin-bottom: 0.25rem; }

.intro { max-width: 760px; font-size: 1.08rem; color: #2b3e42; }
.small-note { color: var(--muted); font-size: 0.9rem; text-align: center; margin: 1rem 0 0; }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.menu-control {
  display: grid;
  gap: 0.4rem;
  font-weight: 800;
}

select {
  padding: 0.75rem;
  border: 1px solid rgba(23, 37, 42, 0.24);
  border-radius: 12px;
  background: white;
}

.button-row { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.button-row.center { justify-content: center; }

.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.lobby-help {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.network-card {
  background: rgba(44, 143, 123, 0.12);
  border: 1px solid rgba(44, 143, 123, 0.3);
  border-radius: 14px;
  padding: 0.9rem;
  display: grid;
  gap: 0.35rem;
}

.network-card span { font-weight: 900; }
.network-card small { color: var(--muted); }

.lobby-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin: 1.2rem 0;
}

.slot-card {
  background: var(--panel2);
  border: 1px solid rgba(23, 37, 42, 0.14);
  border-radius: 16px;
  padding: 1rem;
  display: grid;
  gap: 0.7rem;
}

.slot-card input {
  width: 100%;
  border: 1px solid rgba(23, 37, 42, 0.2);
  border-radius: 10px;
  padding: 0.55rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.8rem;
  background: rgba(255, 248, 224, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.16);
}

.topbar h2 { margin: 0; }
.top-stats { display: flex; align-items: center; flex-wrap: wrap; gap: 0.55rem; color: #28424a; font-weight: 800; }
.top-stats span { background: rgba(44, 143, 123, 0.13); border-radius: 999px; padding: 0.35rem 0.65rem; }

.status-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}

.player-pill {
  background: rgba(255, 248, 224, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  padding: 0.6rem;
  box-shadow: 0 8px 20px rgba(0,0,0,0.14);
}

.player-pill.active { outline: 3px solid rgba(248, 187, 87, 0.8); }
.player-pill.down { opacity: 0.55; filter: grayscale(0.5); }
.player-pill strong { display: block; font-size: 0.9rem; }
.meter-line { height: 7px; background: rgba(23, 37, 42, 0.13); border-radius: 999px; overflow: hidden; margin-top: 0.35rem; }
.meter-line > span { display: block; height: 100%; background: linear-gradient(90deg, #d85b43, #f3b447, #3b9b58); }

.game-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(300px, 1.15fr) minmax(260px, 1.05fr);
  gap: 0.85rem;
}

.side-panel { grid-column: 1; grid-row: 1; }
.camp-zone { grid-column: 2; grid-row: 1; }
.active-zone { grid-column: 3; grid-row: 1; }

.zone, .side-panel .mini-panel {
  background: rgba(255, 248, 224, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 18px;
  padding: 0.9rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}

.side-panel { display: grid; gap: 0.85rem; align-self: start; }
.zone-heading { display: flex; justify-content: space-between; align-items: start; gap: 0.7rem; margin-bottom: 0.65rem; }
.zone-heading.compact { align-items: center; }
.zone-heading.compact h3 { margin: 0; }
.zone-heading p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.threat-head { margin-top: 1rem; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  background: rgba(44, 143, 123, 0.14);
  color: #146758;
  font-size: 0.78rem;
  font-weight: 900;
}
.badge.danger { background: rgba(184, 63, 50, 0.13); color: var(--danger2); }

.cards {
  min-height: 130px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 0.55rem;
  align-content: start;
}

.card {
  min-height: 148px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  padding: 0.65rem;
  border-radius: 15px;
  border: 2px solid rgba(23, 37, 42, 0.12);
  background: var(--card);
  box-shadow: 0 8px 16px rgba(0,0,0,0.12);
  cursor: pointer;
  user-select: none;
}

.card:hover { transform: translateY(-1px); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(248, 187, 87, 0.35), 0 10px 18px rgba(0,0,0,0.15); }
.card.resource { background: linear-gradient(180deg, #fffced, #f6e6bd); }
.card.threat { background: linear-gradient(180deg, #ffece7, #f0b5aa); border-color: rgba(184, 63, 50, 0.35); }
.card.threat.selected { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(184, 63, 50, 0.25), 0 10px 18px rgba(0,0,0,0.15); }
.card .type { font-size: 0.68rem; font-weight: 900; color: var(--accent2); letter-spacing: 0.08em; text-transform: uppercase; }
.card.threat .type { color: var(--danger2); }
.card .name { font-weight: 950; line-height: 1.06; }
.card .desc { font-size: 0.76rem; color: #435256; flex: 1; }
.card .tags { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tag {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.13rem 0.33rem;
  font-size: 0.65rem;
  font-weight: 800;
  background: rgba(44, 143, 123, 0.14);
  color: #146758;
}
.card.threat .tag { background: rgba(184, 63, 50, 0.12); color: var(--danger2); }
.card .target { font-size: 0.68rem; color: var(--danger2); font-weight: 900; }

.empty-zone {
  padding: 1rem;
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255,255,255,0.38);
  border: 1px dashed rgba(23, 37, 42, 0.18);
}

.radio-progress { display: grid; gap: 0.45rem; margin: 0.6rem 0; }
.radio-stage {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(23, 37, 42, 0.11);
}
.radio-stage.done { background: rgba(47, 143, 72, 0.14); }
.radio-stage strong { font-size: 0.85rem; }
.radio-stage span { font-size: 0.73rem; color: var(--muted); text-align: right; }

.actions-grid { display: grid; gap: 0.55rem; }
.hint-box {
  margin-top: 0.65rem;
  padding: 0.65rem;
  border-radius: 12px;
  background: rgba(44, 143, 123, 0.1);
  color: #204b45;
  font-size: 0.82rem;
  min-height: 58px;
}

.log-panel { max-height: 360px; }
.game-log {
  overflow: auto;
  max-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-right: 0.2rem;
}
.log-entry {
  padding: 0.5rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.45);
  font-size: 0.82rem;
  line-height: 1.25;
}
.log-entry.danger { background: rgba(184, 63, 50, 0.13); }
.log-entry.good { background: rgba(47, 143, 72, 0.14); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 18, 22, 0.72);
  backdrop-filter: blur(6px);
}
.overlay.hidden { display: none; }

.modal-card {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: clamp(1rem, 4vw, 1.8rem);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.65);
}

.morse-output {
  min-height: 58px;
  display: grid;
  place-items: center;
  margin: 1rem 0;
  border-radius: 14px;
  background: #12252d;
  color: #b9ffd8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.45rem;
  letter-spacing: 0.12em;
}
.morse-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.55rem; margin-bottom: 0.6rem; }

@media (max-width: 1060px) {
  .game-layout { grid-template-columns: minmax(240px, 0.9fr) minmax(260px, 1.1fr); }
  .side-panel { grid-column: 1; grid-row: 1 / span 2; grid-template-columns: 1fr; }
  .active-zone { grid-column: 2; grid-row: 1; }
  .camp-zone { grid-column: 2; grid-row: 2; }
  .log-panel { max-height: none; }
}

@media (max-width: 760px) {
  .screen { padding: 0.7rem; }
  .hero-card, .panel { margin: 1rem auto; }
  .menu-grid, .lobby-help, .game-layout, .side-panel { grid-template-columns: 1fr; }
  .side-panel, .active-zone, .camp-zone { grid-column: 1; grid-row: auto; }
  .topbar, .screen-header { align-items: stretch; flex-direction: column; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .card { min-height: 142px; }
  .morse-buttons { grid-template-columns: repeat(2, 1fr); }
}

/* Menus and instructions */
.compact-header { margin-bottom: 0.75rem; }
.menu-modal { width: min(620px, 100%); }
.menu-stack {
  display: grid;
  gap: 0.7rem;
  margin: 1rem 0;
}
.left-note { text-align: left; }
.danger-text { color: var(--danger2); font-weight: 900; }
.menu-help {
  color: var(--muted);
  margin-bottom: 1rem;
}
.kick-list {
  display: grid;
  gap: 0.65rem;
}
.kick-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.8rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.52);
  border: 1px solid rgba(23, 37, 42, 0.12);
}
.kick-row.active { outline: 3px solid rgba(248, 187, 87, 0.45); }
.kick-row.down { opacity: 0.62; }
.kick-row strong { display: block; }
.kick-row small { color: var(--muted); }

.instruction-card {
  width: min(1040px, 100%);
  max-height: 92vh;
}
.rules-tabs {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin: 0.6rem 0 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(23, 37, 42, 0.14);
}
.rules-tab {
  padding: 0.55rem 0.72rem;
  font-size: 0.88rem;
  box-shadow: none;
  background: rgba(255,255,255,0.54);
  border: 1px solid rgba(23, 37, 42, 0.12);
}
.rules-tab.active {
  background: linear-gradient(180deg, #f8bb57, var(--accent));
  font-weight: 900;
}
.rules-content {
  line-height: 1.46;
}
.rules-panel { display: none; }
.rules-panel.active { display: block; }
.rules-panel h3 { font-size: 1.35rem; margin-top: 0.2rem; }
.rules-list {
  padding-left: 1.25rem;
  margin: 0.4rem 0 1rem;
}
.rules-list li { margin-bottom: 0.45rem; }
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  margin: 0.75rem 0 1rem;
}
.rule-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.8rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(23, 37, 42, 0.12);
}
.rule-card strong { color: #17383d; }
.rule-card span { color: #3d5054; }
.highlight-rule {
  background: rgba(44, 143, 123, 0.13);
  border-color: rgba(44, 143, 123, 0.25);
  margin: 0.85rem 0;
}
.confirm-card { width: min(520px, 100%); }

@media (max-width: 760px) {
  .kick-row { grid-template-columns: 1fr; }
  .rules-tabs { display: grid; grid-template-columns: repeat(2, 1fr); }
}

/* Code-drawn card art */
.card { min-height: 238px; }
.card .name { min-height: 2.1em; }
.card-art-wrap {
  width: 100%;
  aspect-ratio: 5 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.38);
  border: 1px solid rgba(23, 37, 42, 0.13);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
  flex: 0 0 auto;
}
.card-art-svg { width: 100%; height: 100%; display: block; }
.art-frame { fill: rgba(255,255,255,0.25); stroke: rgba(23, 37, 42, 0.22); stroke-width: 4; }
.card.threat .art-frame { stroke: rgba(110, 28, 25, 0.32); }
.card .desc { min-height: 3.7em; }
.resource-art.radio-art { background: #dceff1; }
.resource-art.medical-art { background: #e4efe3; }
.resource-art.food-art { background: #f4dc98; }
.resource-art.fire-art { background: #f1bc72; }
.threat-art { background: #e0a090; }

.rules-content {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 0.3rem;
}
.instruction-card {
  height: min(780px, calc(100vh - 2rem));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.rules-art-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: 0.55rem;
  margin: 0.7rem 0 1rem;
}
.rules-art-row.compact-examples {
  grid-template-columns: repeat(auto-fit, minmax(120px, 150px));
}
.instruction-card-preview {
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.56);
  border: 1px solid rgba(23, 37, 42, 0.12);
  min-width: 0;
}
.instruction-card-preview.threat {
  background: rgba(255,236,231,0.68);
  border-color: rgba(184,63,50,0.18);
}
.preview-title {
  font-size: 0.78rem;
  font-weight: 950;
  line-height: 1.05;
  color: #17383d;
}
.preview-tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.instruction-card-preview .tag { font-size: 0.58rem; padding: 0.1rem 0.28rem; }
.instruction-card-preview.threat .tag { background: rgba(184, 63, 50, 0.12); color: var(--danger2); }

@media (max-width: 760px) {
  .card { min-height: 224px; }
  .rules-art-row, .rules-art-row.compact-examples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .instruction-card { height: calc(100vh - 1rem); }
}

/* Explicit draw step, feedback, and sounds */
.sound-button {
  width: 2.55rem;
  min-width: 2.55rem;
  padding-left: 0;
  padding-right: 0;
  font-size: 1rem;
}

.draw-action {
  position: relative;
  overflow: hidden;
}

.draw-action.draw-highlight:not(:disabled) {
  animation: drawButtonPulse 1.05s ease-in-out infinite;
  box-shadow: 0 0 0 4px rgba(248, 187, 87, 0.28), 0 6px 0 rgba(0, 0, 0, 0.18);
}

.draw-action.draw-highlight:not(:disabled)::after {
  content: "";
  position: absolute;
  inset: -45% -70%;
  background: linear-gradient(110deg, transparent 42%, rgba(255, 255, 255, 0.62) 50%, transparent 58%);
  animation: drawButtonSheen 1.4s linear infinite;
  pointer-events: none;
}

@keyframes drawButtonPulse {
  0%, 100% { transform: translateY(0) scale(1); filter: brightness(1); }
  50% { transform: translateY(-1px) scale(1.025); filter: brightness(1.08); }
}

@keyframes drawButtonSheen {
  from { transform: translateX(-60%); }
  to { transform: translateX(60%); }
}

.card.draw-placeholder {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

.card.new-card {
  animation: newCardPop 0.55s cubic-bezier(.2, 1.15, .34, 1) both;
}

.card.new-threat {
  animation: threatDrop 0.55s cubic-bezier(.18, .9, .3, 1.15) both;
}

@keyframes newCardPop {
  0% { transform: translateY(-8px) scale(0.88) rotate(-2deg); opacity: 0; }
  65% { transform: translateY(2px) scale(1.04) rotate(1deg); opacity: 1; }
  100% { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
}

@keyframes threatDrop {
  0% { transform: translateY(-18px) rotate(-2deg); opacity: 0; }
  70% { transform: translateY(2px) rotate(1deg); opacity: 1; }
  100% { transform: translateY(0) rotate(0); opacity: 1; }
}

.draw-flyer {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  border-radius: 15px;
  transition-property: left, top, width, height, transform, opacity;
  transition-duration: 620ms;
  transition-timing-function: cubic-bezier(.15, .85, .22, 1.05);
  transform: rotate(-8deg) scale(0.9);
  opacity: 0.98;
  filter: drop-shadow(0 18px 18px rgba(0,0,0,0.32));
}

.draw-flyer.fly {
  transform: rotate(0deg) scale(1);
  opacity: 1;
}

.draw-flyer-back {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.3rem;
  border-radius: 15px;
  border: 3px solid rgba(23, 37, 42, 0.45);
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,0.38) 0 24%, transparent 25%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.15) 0 8px, transparent 8px 16px),
    linear-gradient(160deg, #2c8f7b, #1f5e68 52%, #11313b);
  color: #fff6d7;
  text-align: center;
  box-shadow: inset 0 0 0 6px rgba(255,255,255,0.14);
}

.draw-flyer-back span {
  font-size: 0.6rem;
  font-weight: 950;
  letter-spacing: 0.16em;
}

.draw-flyer-back b {
  font-size: 1.15rem;
  letter-spacing: 0.08em;
}

@media (prefers-reduced-motion: reduce) {
  .draw-action.draw-highlight:not(:disabled),
  .draw-action.draw-highlight:not(:disabled)::after,
  .card.new-card,
  .card.new-threat {
    animation: none;
  }
  .draw-flyer { transition-duration: 1ms; }
}

/* Cleanup choices and celebratory end screen */
.card.locked-card {
  opacity: 0.72;
  filter: saturate(0.75);
}
.card.locked-card::after {
  content: "NEXT SURVIVOR";
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.16rem 0.38rem;
  border-radius: 999px;
  background: rgba(18, 37, 45, 0.82);
  color: #fff4d5;
  font-size: 0.55rem;
  font-weight: 950;
  letter-spacing: 0.04em;
}

.win-card {
  width: min(720px, 100%);
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(248,187,87,0.32), transparent 42%),
    var(--panel);
}
.win-card h2 {
  font-size: clamp(2rem, 7vw, 4.2rem);
  margin: 0.2rem 0 0.4rem;
  color: #17383d;
  text-shadow: 0 2px 0 rgba(255,255,255,0.65);
}
.winner-label {
  display: inline-flex;
  margin: 0.2rem auto 0.35rem;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #f8bb57, var(--accent));
  color: #5a310f;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}
.winner-name {
  font-size: clamp(2.1rem, 9vw, 5.3rem);
  font-weight: 1000;
  line-height: 0.98;
  color: var(--good);
  margin-bottom: 0.45rem;
}
.win-subtext {
  max-width: 58ch;
  margin: 0 auto 1rem;
  color: #3d5054;
}
.team-ranking-block {
  text-align: left;
  margin: 1rem 0;
  padding: 0.9rem;
  border-radius: 16px;
  background: rgba(255,255,255,0.54);
  border: 1px solid rgba(23, 37, 42, 0.12);
}
.team-ranking-block h3 { margin: 0 0 0.6rem; }
.win-team-list {
  display: grid;
  gap: 0.55rem;
}
.win-rank-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.65rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.6);
}
.win-rank-row.down { opacity: 0.62; }
.win-rank-row.solo { grid-template-columns: 1fr; text-align: center; }
.rank-number {
  display: inline-grid;
  place-items: center;
  min-width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: rgba(44,143,123,0.16);
  font-weight: 950;
  color: var(--good);
}

@media (max-width: 760px) {
  .win-rank-row { grid-template-columns: auto 1fr; }
  .win-rank-row span:last-child { grid-column: 2; }
}

/* ---- Online multiplayer UI ---- */
.online-block {
	margin-top: 18px;
	padding-top: 16px;
	border-top: 1px solid rgba(23, 37, 42, 0.15);
	display: grid;
	gap: 12px;
}

.online-block .menu-control {
	max-width: 320px;
	margin: 0 auto;
	width: 100%;
}

.join-panel {
	display: flex;
	gap: 10px;
	justify-content: center;
	align-items: center;
}

.join-panel.hidden {
	display: none;
}

.join-panel input {
	width: 140px;
	text-transform: uppercase;
	letter-spacing: 0.35em;
	text-align: center;
	font-weight: 700;
	font-size: 1.1rem;
	padding: 10px 12px;
	border-radius: 12px;
	border: 2px solid rgba(23, 37, 42, 0.25);
	background: var(--panel2);
	color: var(--ink);
}

.online-roster {
	display: grid;
	gap: 8px;
	margin: 6px 0 14px;
}

.roster-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	border-radius: 12px;
	background: var(--panel2);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.roster-row strong {
	color: var(--ink);
}

.roster-row span {
	color: var(--muted);
	font-size: 0.85rem;
}

.roster-row.ai {
	opacity: 0.72;
	background: rgba(255, 255, 255, 0.6);
}

/* Sticky survivor stats below the main top bar */
.status-bar {
  position: sticky;
  top: 5.75rem;
  z-index: 3;
  padding: 0.15rem;
  border-radius: 16px;
  background: rgba(13, 30, 36, 0.18);
  backdrop-filter: blur(4px);
}

/* Nature draw, played-set, and threat poof animations */
.card.threat-placeholder {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

.threat-flyer {
  perspective: 900px;
}

.threat-flyer-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 420ms cubic-bezier(.2,.8,.25,1.2);
}

.threat-flyer.flip .threat-flyer-inner {
  transform: rotateY(180deg);
}

.threat-flyer .draw-flyer-back,
.threat-flyer-front {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 15px;
  overflow: hidden;
}

.danger-card-back {
  background:
    radial-gradient(circle at 50% 45%, rgba(255,226,198,0.26) 0 22%, transparent 23%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.1) 0 7px, transparent 7px 15px),
    linear-gradient(160deg, #b83f32, #6e1c19 54%, #25100f) !important;
}

.threat-flyer-front {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #ffece7, #f0b5aa);
  border: 3px solid rgba(110, 28, 25, 0.45);
}

.mini-threat-card {
  height: 100%;
  display: grid;
  gap: 0.26rem;
  padding: 0.48rem;
  color: var(--ink);
  font-size: 0.76rem;
}

.mini-threat-card .type {
  font-size: 0.58rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  color: var(--danger2);
  text-transform: uppercase;
}

.mini-threat-card .name {
  font-size: 0.92rem;
  line-height: 1;
  font-weight: 950;
}

.mini-threat-card .card-art-wrap {
  min-height: 0;
}

.mini-threat-card .target {
  font-size: 0.62rem;
  color: var(--danger2);
  font-weight: 900;
}

.card.card-played-out {
  pointer-events: none;
  animation: playedCardOut 520ms cubic-bezier(.25,.8,.2,1) forwards;
}

.card.threat-poof {
  pointer-events: none;
  animation: threatPoof 720ms cubic-bezier(.16,.75,.2,1) forwards;
  z-index: 2;
}

@keyframes playedCardOut {
  0% { transform: translateY(0) scale(1); opacity: 1; filter: brightness(1); }
  45% { transform: translateY(-18px) scale(1.04) rotate(1deg); opacity: 0.92; filter: brightness(1.12); }
  100% { transform: translateY(-46px) scale(0.78) rotate(-5deg); opacity: 0; filter: brightness(1.25); }
}

@keyframes threatPoof {
  0% { transform: scale(1) rotate(0); opacity: 1; filter: brightness(1); }
  38% { transform: scale(1.12) rotate(2deg); opacity: 1; filter: brightness(1.35); box-shadow: 0 0 0 8px rgba(248,187,87,0.22); }
  70% { transform: scale(0.92) rotate(-7deg); opacity: 0.45; filter: blur(1px) brightness(1.7); }
  100% { transform: scale(0.25) rotate(14deg); opacity: 0; filter: blur(6px) brightness(2); }
}

/* Gentle across-screen guidance for stuck players */
.coach-toast {
  position: fixed;
  left: 50%;
  top: 19%;
  z-index: 90;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 2rem));
  padding: 1rem 1.25rem;
  border-radius: 999px;
  background: rgba(255, 248, 224, 0.96);
  border: 2px solid rgba(248, 187, 87, 0.78);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  color: #17383d;
  text-align: center;
  font-weight: 950;
  letter-spacing: 0.01em;
  pointer-events: none;
  animation: coachSlide 300ms ease both;
}

.coach-toast.hidden {
  display: none;
}

@keyframes coachSlide {
  from { opacity: 0; transform: translate(-50%, -12px) scale(0.98); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* Short rescue cinematic */
.cinematic-overlay {
  background: rgba(9, 21, 28, 0.78);
}

.rescue-scene {
  position: relative;
  width: min(920px, calc(100vw - 1.5rem));
  height: min(520px, calc(100vh - 1.5rem));
  overflow: hidden;
  border-radius: 28px;
  background:
    linear-gradient(180deg, #87d8ef 0 52%, #2fa9c9 53% 71%, #0d6d8a 72% 100%);
  box-shadow: 0 28px 80px rgba(0,0,0,0.48);
  border: 3px solid rgba(255,255,255,0.62);
}

.sun-orb {
  position: absolute;
  width: 6.5rem;
  height: 6.5rem;
  border-radius: 50%;
  right: 8%;
  top: 10%;
  background: radial-gradient(circle, #fff1a5, #f8bb57 70%);
  box-shadow: 0 0 46px rgba(248,187,87,0.7);
}

.rescue-cloud {
  position: absolute;
  width: 11rem;
  height: 3.2rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.82);
  filter: blur(0.2px);
  animation: cloudDrift 3.6s linear both;
}

.rescue-cloud::before,
.rescue-cloud::after {
  content: "";
  position: absolute;
  bottom: 0.8rem;
  border-radius: 50%;
  background: inherit;
}
.rescue-cloud::before { width: 4.8rem; height: 4.8rem; left: 1.2rem; }
.rescue-cloud::after { width: 6rem; height: 6rem; right: 1.2rem; }
.cloud-a { left: 9%; top: 18%; }
.cloud-b { right: -8%; top: 28%; animation-delay: 250ms; }

.rescue-plane {
  position: absolute;
  left: -16%;
  top: 24%;
  font-size: clamp(3.6rem, 11vw, 7.5rem);
  color: #fffdf2;
  text-shadow: 0 10px 16px rgba(0,0,0,0.28);
  transform: rotate(7deg);
  animation: rescuePlane 3.25s cubic-bezier(.18,.68,.25,1) both;
  z-index: 3;
}

.rescue-water {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: 0;
  height: 30%;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.18) 0 4px, transparent 4px 18px),
    linear-gradient(180deg, rgba(52,191,218,0.7), #0d6d8a);
}

.rescue-island {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  width: min(420px, 72vw);
  height: 12rem;
  z-index: 2;
}

.island-hump {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5.5rem;
  border-radius: 50% 50% 18% 18%;
  background: linear-gradient(180deg, #f3d489, #c9853e);
  box-shadow: inset 0 -12px 0 rgba(132,82,36,0.22);
}

.palm.trunk {
  position: absolute;
  left: 48%;
  bottom: 4rem;
  width: 0.85rem;
  height: 6.7rem;
  background: #80552c;
  border-radius: 999px;
  transform: rotate(8deg);
  transform-origin: bottom;
}

.palm.leaves {
  position: absolute;
  left: 42%;
  bottom: 9.6rem;
  font-size: 4.8rem;
  color: #257944;
  text-shadow: 0 3px 0 rgba(0,0,0,0.12);
}

.signal-smoke {
  position: absolute;
  bottom: 8.5rem;
  left: 28%;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: rgba(245,245,235,0.78);
  animation: smokeRise 2.1s ease-out infinite;
}
.smoke-two { animation-delay: 620ms; left: 31%; }

.cinematic-caption {
  position: absolute;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  width: min(620px, calc(100% - 2rem));
  padding: 0.8rem 1rem;
  border-radius: 999px;
  background: rgba(255,248,224,0.94);
  color: #17383d;
  font-weight: 950;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0,0,0,0.2);
  animation: captionPop 650ms ease 2.2s both;
}

@keyframes rescuePlane {
  0% { left: -18%; top: 38%; transform: rotate(8deg) scale(0.72); opacity: 0.2; }
  28% { opacity: 1; }
  82% { left: 51%; top: 14%; transform: rotate(5deg) scale(1.02); opacity: 1; }
  100% { left: 72%; top: 7%; transform: rotate(4deg) scale(0.88); opacity: 0.9; }
}

@keyframes cloudDrift {
  from { transform: translateX(0); }
  to { transform: translateX(-60px); }
}

@keyframes smokeRise {
  0% { transform: translateY(0) scale(0.65); opacity: 0; }
  28% { opacity: 0.72; }
  100% { transform: translateY(-82px) scale(1.55); opacity: 0; }
}

@keyframes captionPop {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 760px) {
  .status-bar { top: 8.6rem; }
  .coach-toast { top: 13%; border-radius: 20px; }
  .rescue-scene { height: min(480px, calc(100vh - 1rem)); }
}

@media (prefers-reduced-motion: reduce) {
  .card.card-played-out,
  .card.threat-poof,
  .rescue-plane,
  .rescue-cloud,
  .signal-smoke,
  .cinematic-caption {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* 2026-07 update: deck source, split center windows, hunger dots, and win carry-on */
.player-strip {
  position: sticky;
  top: 5.75rem;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(92px, 116px) 1fr;
  gap: 0.65rem;
  align-items: stretch;
  margin-bottom: 0.8rem;
  padding: 0.2rem;
  border-radius: 18px;
  background: rgba(13, 30, 36, 0.18);
  backdrop-filter: blur(4px);
}

.player-strip .status-bar {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
  margin-bottom: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
}

.deck-visual {
  position: relative;
  min-height: 86px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 248, 224, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow: 0 8px 20px rgba(0,0,0,0.16);
  overflow: hidden;
}

.deck-card-stack {
  position: relative;
  width: 58px;
  height: 78px;
}

.deck-card {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.12rem;
  border-radius: 10px;
  border: 2px solid rgba(23, 37, 42, 0.45);
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,0.38) 0 24%, transparent 25%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.15) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #2c8f7b, #1f5e68 52%, #11313b);
  color: #fff6d7;
  text-align: center;
  box-shadow: inset 0 0 0 4px rgba(255,255,255,0.14), 0 8px 12px rgba(0,0,0,0.18);
}

.deck-card.layer-a { transform: translate(-6px, 5px) rotate(-7deg); opacity: 0.82; }
.deck-card.layer-b { transform: translate(5px, 2px) rotate(6deg); opacity: 0.9; }
.deck-card.face { transform: translate(0, 0) rotate(0); }
.deck-card span { font-size: 0.48rem; font-weight: 950; letter-spacing: 0.14em; }
.deck-card b { font-size: 0.84rem; letter-spacing: 0.08em; }
.deck-card small {
  display: inline-grid;
  place-items: center;
  min-width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: rgba(255, 246, 215, 0.92);
  color: #17383d;
  font-weight: 950;
}

.deck-visual.shuffle-anim .layer-a { animation: deckShuffleA 720ms ease both; }
.deck-visual.shuffle-anim .layer-b { animation: deckShuffleB 720ms ease both; }
.deck-visual.shuffle-anim .face { animation: deckShuffleFace 720ms ease both; }

@keyframes deckShuffleA {
  0%, 100% { transform: translate(-6px, 5px) rotate(-7deg); }
  25% { transform: translate(18px, -4px) rotate(14deg); }
  52% { transform: translate(-15px, 1px) rotate(-14deg); }
  76% { transform: translate(7px, 5px) rotate(8deg); }
}
@keyframes deckShuffleB {
  0%, 100% { transform: translate(5px, 2px) rotate(6deg); }
  22% { transform: translate(-19px, -3px) rotate(-13deg); }
  55% { transform: translate(16px, 2px) rotate(16deg); }
  78% { transform: translate(-6px, 4px) rotate(-7deg); }
}
@keyframes deckShuffleFace {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(0, -8px) rotate(-5deg); }
  45% { transform: translate(13px, 0) rotate(9deg); }
  70% { transform: translate(-12px, 2px) rotate(-8deg); }
}

.game-layout {
  grid-template-columns: minmax(260px, 0.85fr) minmax(300px, 1.15fr) minmax(260px, 1.05fr);
}

.center-panel {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  gap: 0.85rem;
  align-self: start;
}

.side-panel { grid-column: 1; grid-row: 1; }
.active-zone { grid-column: 3; grid-row: 1; }
.nature-zone, .camp-zone { grid-column: auto; grid-row: auto; }

.action-strong { font-weight: 950; }

.danger-action {
  background: rgba(184, 63, 50, 0.13);
  color: #6e1c19;
  border-color: rgba(184, 63, 50, 0.24);
  font-weight: 950;
}
.danger-action:hover:not(:disabled) { background: rgba(184, 63, 50, 0.22); }

.player-pill-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}
.player-pill-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.food-meter {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 950;
  color: #7a4b14;
}
.food-meter b { margin-right: 0.1rem; }
.food-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 999px;
  border: 1px solid rgba(30, 85, 35, 0.45);
  background: #c93b32;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
.food-dot.filled {
  background: #37b85b;
  border-color: rgba(18, 105, 42, 0.7);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.25), 0 0 8px rgba(55,184,91,0.28);
}
.food-dot.empty {
  opacity: 1;
  border-color: rgba(122, 21, 16, 0.65);
  background: #c93b32;
}

.meter-line.health > span { background: linear-gradient(90deg, #d85b43, #f3b447, #3b9b58); }
.meter-line.morale > span { background: linear-gradient(90deg, #2557bd, #2e8be6, #6cc8ff); }

.carry-on-win {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 75;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.4rem;
  background: linear-gradient(180deg, #f8bb57, #d9822b);
  color: #17252a;
  font-weight: 950;
  box-shadow: 0 16px 44px rgba(0,0,0,0.32);
}
.carry-on-win.hidden { display: none; }

@media (max-width: 880px) {
  .player-strip {
    top: 8.6rem;
    grid-template-columns: 1fr;
  }
  .deck-visual { min-height: 72px; }
  .game-layout, .side-panel, .center-panel { grid-template-columns: 1fr; }
  .side-panel, .center-panel, .active-zone, .nature-zone, .camp-zone { grid-column: 1; grid-row: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .deck-visual.shuffle-anim .deck-card { animation-duration: 1ms !important; }
}
