/* Only the active table fills the viewport; home, lobby and modal bodies retain their flow. */
body.playing { height: 100dvh; overflow: hidden; }
.playing > header { display: none; }
.playing > main {
  width: 100%; max-width: none; height: 100dvh; padding: 0;
  display: grid; grid-template-rows: 40px minmax(0, 1fr); overflow: hidden;
}
.game-rail {
  display: flex; align-items: center; gap: 12px; padding: 0 12px;
  min-width: 0; border-bottom: 1px solid #e6b65d35; background: #102b28;
  color: var(--muted); font-size: 14px;
}
.rail-brand { color: var(--paper); font: bold 18px Georgia, serif; white-space: nowrap; }
.rail-brand em { color: var(--gold); }
.rail-connection { width: 6px; height: 6px; border-radius: 50%; background: #db955e; flex: 0 0 auto; }
.rail-connection.online { background: #a9cbb7; }
.rail-round { color: var(--gold); font-weight: 750; }
.rail-boss { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-menu { margin-left: auto; display: flex; gap: 2px; flex: 0 0 auto; }
.rail-icon { display: grid; place-items: center; width: 36px; height: 36px; padding: 7px; border: 0; background: none; }
.rail-icon svg { width: 20px; height: 20px; }
.playing .play-board {
  height: 100%; min-height: 0; min-width: 0;
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 50%);
}
.playing .obstacle-stage {
  min-height: 0; padding: 8px 16px; gap: 16px;
  grid-template-columns: minmax(36px, 1fr) minmax(0, 900px) minmax(36px, 1fr);
  overflow: hidden;
}
.playing .active-obstacle { height: 100%; min-height: 0; }
.playing .active-obstacle .encounter.encounter-panel {
  color: var(--paper); height: 100%; min-height: 0; overflow: hidden;
  align-content: center; grid-template-rows: auto minmax(0, auto); padding: 8px 14px;
}
.encounter-details-button { margin-left: auto; padding: 0 5px; font-size: 20px; }
.playing .encounter-copy { overflow: hidden; }
.playing .encounter-copy h3 { color: #fff0c7; }
.playing .encounter-copy p { color: var(--paper); }
.playing .encounter-copy .encounter-special,
.playing .encounter-reward p {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.playing .encounter-panel .committed { display: none; }
.playing .encounter-art { align-self: center; }
.playing .encounter-art img { max-height: 18dvh; }
.playing .completed-obstacles { max-height: 100%; overflow: hidden; }
.playing .middle-rail {
  grid-template-columns: 54px 54px minmax(160px, 250px) 54px 54px 120px;
  padding: 4px 12px; gap: 10px; z-index: 2;
}
.playing .skill { min-height: 0; height: 62px; padding: 2px; gap: 0; }
.playing .skill .skill-icon { width: 32px; height: 32px; }
.playing .skill small { font-size: 12px; }
.playing .challenge-rating { gap: 0; grid-template-columns: 1fr 1fr; align-items: center; }
.playing .challenge-rating > span:first-child { font-size: 16px; }
.playing .challenge-rating > strong { font-size: 30px; grid-column: 2; grid-row: 1 / 3; }
.playing .challenge-rating > span { font-size: 12px; }
.playing .challenge-rating > small { grid-column: 1 / -1; font-size: 12px; }
.playing .roll-button { grid-column: auto; min-height: 54px; min-width: 0; width: 100%; padding: 5px; }
.playing .hand-zone {
  min-height: 0; position: relative; padding: 0 12px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 32px minmax(0, 1fr);
  background: radial-gradient(ellipse at bottom, #35524955, transparent 70%);
}
.playing .hand-head { grid-column: 1; grid-row: 1; margin: 0; padding: 0; gap: 8px; flex-wrap: nowrap; }
.playing .hand-head h2 { font-size: 16px; white-space: nowrap; }
.playing .hand-head > span { font-size: 12px; margin-left: 10px; flex-basis: auto; order: 0; }
.playing .hand-head > button { margin: 0; padding: 2px 6px; font-size: 18px; }
.hand-actions { grid-row: 1; grid-column: 2; align-self: center; position: relative; z-index: 300; }
.hand-actions > summary { cursor: pointer; color: var(--gold); font-size: 14px; padding: 5px 8px; }
.hand-actions > .context-actions {
  position: absolute; right: 0; bottom: calc(100% + 8px); width: min(420px, 90vw);
  padding: 12px; background: #173b34; border: 1px solid #b89652; box-shadow: 0 8px 30px #0008;
  max-height: 65dvh; overflow: auto;
}
.hand-actions .encounter-tools { align-items: stretch; }
.hand-actions .encounter-tools > details { margin: 0; flex-basis: 100%; }
.hand-actions .encounter-tools details > div { position: static; box-shadow: none; }
.hand-actions .power { margin-top: 8px; }
.playing .hand {
  grid-column: 1 / -1; grid-row: 2; display: block; height: 100%; min-height: 0;
  padding: 0; margin: 0; overflow-x: auto; overflow-y: hidden;
  overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #b8965280 transparent;
  touch-action: pan-x;
}
.hand-fan {
  width: var(--track-width, 100%); height: 100%; display: flex; align-items: flex-end;
  justify-content: center; padding: 32px 48px 22px; isolation: isolate;
}
.playing .hand .hand-card.framed-hand {
  flex: 0 0 var(--card-width, 150px); width: var(--card-width, 150px); max-height: none;
  align-self: auto; padding: 0; margin: 0; position: relative;
  transform-origin: 50% 90%; transform: translateY(var(--fan-drop, 0px)) rotate(var(--fan-angle, 0deg));
  z-index: var(--card-order, 1); border: 0; background: transparent;
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
  box-shadow: -5px 3px 12px #0006;
}
.playing .hand .hand-card + .hand-card { margin-left: calc(var(--card-step) - var(--card-width)); }
.playing .hand .hand-card.selected,
.playing .hand .hand-card:focus-visible {
  transform: translateY(-22px) rotate(0deg); z-index: 200;
  box-shadow: 0 0 0 3px var(--gold), 0 8px 20px #0008; filter: brightness(1.12);
}
@media (hover: hover) {
  .playing .hand .hand-card:hover:not(:disabled) {
    transform: translateY(-22px) rotate(0deg); z-index: 210; filter: brightness(1.12);
  }
}
.playing .hand .frame-description { overflow: hidden; font-size: max(10px, 4.7cqw); }
.playing .hand .frame-skills { scrollbar-width: none; }
.game-details { color: var(--paper); }
.game-details > article { padding: 12px; background: #173b34; margin-bottom: 12px; }
.game-details .encounter-panel { max-width: none; color: var(--paper); cursor: default; }
.game-details .encounter-status { margin-bottom: 12px; }
.game-details .encounter-art { display: none; }
.game-details .encounter-copy, .game-details .encounter-copy p { display: block; overflow: visible; }
.game-details .party { display: grid; grid-template-columns: 1fr; }
.game-details .player-counts { display: block; }
.game-details li { padding: 8px 0; line-height: 1.5; }
@media (max-width: 760px) {
  .game-rail { gap: 6px; padding-inline: 6px; }
  .rail-brand { font-size: 14px; }
  .rail-progress, .rail-boss { display: none; }
  .rail-icon { width: 32px; height: 36px; padding: 6px; }
  .playing .middle-rail { grid-template-columns: 42px 42px minmax(105px, 1fr) 42px 42px 64px; gap: 4px; padding-inline: 4px; }
  .playing .challenge-rating { display: flex; flex-direction: column; }
  .playing .challenge-rating > strong { font-size: 24px; }
  .playing .challenge-rating > small { display: none; }
  .playing .challenge-rating > span:first-child { font-size: 14px; }
  .playing .roll-button { font-size: 16px; }
  .playing .roll-button > span { display: none; }
  .playing .obstacle-stage { grid-template-columns: 28px minmax(0, 1fr) 12px; padding: 5px; gap: 5px; }
  .playing .active-obstacle .encounter.encounter-panel { grid-template-columns: minmax(0, 1fr); padding: 5px 8px; gap: 4px; }
  .playing .encounter-art { display: none; }
  .playing .encounter-copy h3 { font-size: 22px; }
  .playing .encounter-treatments small { flex-basis: auto; }
  .playing .encounter-treatments > div { flex-wrap: nowrap; }
  .playing .hand-head > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 0; }
  .playing .hand-zone { padding-inline: 5px; }
  .playing .hand-head h2 { font-size: 14px; }
  .playing .hand-head { gap: 3px; }
}
@media (max-width: 410px) {
  .rail-brand { max-width: 78px; overflow: hidden; text-overflow: ellipsis; }
  .rail-round { font-size: 12px; }
  .playing .hand-head > span { font-size: 11px; }
}
@media (max-height: 600px) {
  .playing > main { grid-template-rows: 36px minmax(0, 1fr); }
  .playing .play-board { grid-template-rows: minmax(0, 1fr) auto minmax(0, 50%); }
  .playing .skill { height: 50px; }
  .playing .skill .skill-icon { width: 26px; height: 26px; }
  .playing .roll-button { min-height: 46px; }
  .playing .encounter-copy h3 { font-size: 20px; margin-bottom: 2px; }
  .playing .encounter-copy p { font-size: 12px; margin: 2px 0; }
  .playing .encounter-status { font-size: 12px; }
  .playing .encounter-art { display: none; }
  .playing .active-obstacle .encounter.encounter-panel { grid-template-columns: 1fr; gap: 2px; padding-block: 4px; align-content: start; }
  .playing .encounter-treatments .skill-icon { width: 22px; height: 22px; }
  .playing .encounter-reward { padding-top: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  .playing .hand .hand-card.framed-hand { transition: none; }
}

.playing .game-details .encounter-copy .encounter-special,
.playing .game-details .encounter-reward p {
  display: block; overflow: visible; -webkit-line-clamp: unset;
}
.playing .game-details .encounter-panel .committed { display: block; }

.playing .next-round-button { font-size: 16px; line-height: 1.15; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .playing .next-round-button { font-size: 14px; }
}

/* The primary action and its complete roll conditions share the center slot. */
.playing .middle-rail {
  grid-template-columns: 54px 54px minmax(200px, 330px) 54px 54px;
}
.roll-center { display: flex; align-items: center; justify-content: center; gap: 14px; min-width: 0; }
.playing .roll-center .roll-button { width: auto; flex: 1; font-size: 19px; }
.roll-details { display: grid; gap: 3px; font-size: 14px; text-align: left; line-height: 1.2; }
.roll-treatment { color: var(--muted); }
.survival-range { color: #ffe9ab; white-space: nowrap; }
.roll-details small { font-size: 12px; }
.playing .skill.treatment-advantage { border-bottom-color: #70c89d; }
.playing .skill.treatment-disadvantage { border-bottom-color: #cf806e; }
.health-heart { position: relative; width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; }
.health-heart img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.health-heart b { position: relative; color: white; font: 800 19px/1 system-ui, sans-serif; text-shadow: 0 2px 3px #000, 0 0 4px #000; padding-bottom: 2px; }
.health-hit { animation: health-damage 750ms ease-out; }
@keyframes health-damage {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  15% { transform: scale(1.2) rotate(-12deg); filter: brightness(1.8); }
  35% { transform: scale(.88) rotate(10deg); }
  55% { transform: scale(1.1) rotate(-6deg); }
  75% { transform: scale(.96); }
}
.playing .active-obstacle .encounter.compact-encounter {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  align-items: stretch; padding: 12px 32px; background: transparent; border: 0;
}
.compact-encounter .encounter-details-button { position: absolute; top: 8px; right: 2px; }
.playing .compact-encounter .encounter-copy h3 { font-size: clamp(24px, 3vw, 38px); margin-bottom: 12px; }
.playing .compact-encounter .encounter-copy p { margin: 5px 0; font-size: 14px; }
.playing .compact-encounter .encounter-reward { margin-top: 8px; }
@media (max-width: 760px) {
  .playing .middle-rail { grid-template-columns: 40px 40px minmax(145px, 1fr) 40px 40px; gap: 4px; }
  .roll-center { gap: 5px; }
  .playing .roll-center .roll-button { font-size: 16px; }
  .roll-details { font-size: 12px; }
  .playing .active-obstacle .encounter.compact-encounter { padding: 8px 22px 8px 8px; }
  .playing .compact-encounter .encounter-copy h3 { font-size: 24px; }
  .rail-brand { display: none; }
}
@media (max-width: 410px) {
  .roll-center { flex-direction: column; gap: 2px; }
  .playing .roll-center .roll-button { min-height: 30px; width: 100%; padding: 2px; }
  .roll-details { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 5px; }
  .roll-details small { font-size: 10px; }
}
@media (max-height: 600px) {
  .health-heart { width: 34px; height: 34px; flex-basis: 34px; }
  .playing .compact-encounter .encounter-copy h3 { font-size: 24px; margin-bottom: 4px; }
  .playing .compact-encounter .encounter-reward { margin-top: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  .health-hit { animation: none; outline: 2px solid #ff9b81; border-radius: 50%; }
}

/* Keep complete labels and roll conditions visible at every viewport size. */
.middle-ribbon { min-width: 0; z-index: 2; }
.playing .middle-rail { grid-template-columns: 72px 72px minmax(120px, 330px) 72px 72px; }
.playing .skill { min-width: 0; width: 100%; height: 64px; }
.playing .skill small { width: 100%; font: 700 12px/1.2 system-ui, sans-serif; white-space: nowrap; overflow: visible; }
.playing .skill.chosen { background: #ffda79; border: 3px solid #fff3bb; outline: 2px solid #d99a27; box-shadow: 0 0 14px #ffd66b99; opacity: 1; transform: translateY(-2px); }
.playing .skill.chosen small { text-decoration: underline; text-underline-offset: 3px; }
.playing .roll-center { display: block; }
.playing .roll-center .roll-button { width: 100%; min-height: 60px; display: flex; flex-direction: column; gap: 3px; line-height: 1.2; }
.playing .roll-conditions { font-size: 12px; font-weight: 600; white-space: normal; }
.roll-notice { text-align: center; padding: 4px 12px; background: #193630; color: #ffe6af; font-size: 12px; line-height: 1.35; max-height: 64px; overflow-y: auto; border-bottom: 1px solid #e6b65d60; }
@media (max-width: 760px) {
  .playing .middle-rail { grid-template-columns: 62px 62px minmax(100px, 1fr) 62px 62px; gap: 4px; padding-inline: 4px; }
}
@media (max-width: 410px) {
  .playing .middle-rail { grid-template-columns: repeat(2, 54px) minmax(0, 1fr) repeat(2, 54px); gap: 3px; padding-inline: 3px; }
  .playing .skill small { font-size: 10px; }
  .playing .roll-center .roll-button { font-size: 14px; padding: 4px 2px; }
  .playing .roll-conditions { font-size: 10px; }
}
@media (max-height: 600px) {
  .playing .skill { height: 52px; }
  .playing .roll-center .roll-button { min-height: 50px; }
  .roll-notice { max-height: 38px; }
}

/* Match the action color to the final odds, including card and curse modifiers. */
.playing .roll-button.roll-advantage { background: #70c89d; border-color: #a4ecc4; color: #102b22; }
.playing .roll-button.roll-advantage:hover:not(:disabled) { background: #92dfb7; }
.playing .roll-button.roll-disadvantage { background: #c44d43; border-color: #ef9b8c; color: #fff; }
.playing .roll-button.roll-disadvantage:hover:not(:disabled) { background: #ad3e36; }
.playing .compact-encounter .encounter-copy { overflow-y: auto; min-height: 0; }
.playing .compact-encounter .encounter-treatments { margin-bottom: 6px; }
.playing .encounter-treatments > div { flex-wrap: wrap; min-width: 0; }
.encounter-treatments .encounter-advantage small { color: #a4ecc4; }
.encounter-treatments .encounter-disadvantage small { color: #ffada0; }

/* Keep the fan transforms and the raised selection state independent of the sheen. */
.playing .hand .hand-card.framed-hand.advantaged-card {
  box-shadow: 0 0 0 2px #edc76e, 0 0 14px #ffc84c99, 0 0 26px #d995303b;
}
.playing .hand .hand-card.framed-hand.advantaged-card.selected,
.playing .hand .hand-card.framed-hand.advantaged-card:focus-visible {
  box-shadow: 0 0 0 3px #fff1b9, 0 0 20px #ffd66bb3, 0 8px 20px #0008;
}
.playing .hand .advantaged-card::after {
  content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, #f8d47430 43%, #fff3be99 49%, #ffffffb0 50%, transparent 60%);
  background-size: 300% 100%; background-position: 150% 0;
  -webkit-mask: url('/assets/cards/player/front.png') center / 100% 100% no-repeat;
  mask: url('/assets/cards/player/front.png') center / 100% 100% no-repeat;
  animation: hand-metallic-shimmer 4.8s ease-in-out infinite;
  animation-delay: calc(var(--card-order, 1) * -0.35s);
}
@keyframes hand-metallic-shimmer {
  0%, 60% { background-position: 150% 0; opacity: 0; }
  68% { opacity: .65; }
  90%, 100% { background-position: -50% 0; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .playing .hand .advantaged-card::after { animation: none; display: none; }
}
