/* The tabletop is a desktop surface; viewport-boundaries.css owns visibility. */
@media (min-width: 561px) {
  .tabletop.stage-panel {
    --table-ink: #0d2024;
    --table-rule: #ffffff27;
    --table-paper: #f4e8ca;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1fr);
    padding: clamp(12px, 1.5vw, 21px);
    border: 1px solid #294449;
    border-radius: 24px;
    background:
      radial-gradient(ellipse at 16% 0%, #24494b, transparent 67%),
      repeating-linear-gradient(135deg, #ffffff04 0 1px, transparent 1px 7px),
      var(--table-ink);
    color: var(--table-paper);
    box-shadow: 0 17px 35px #122c2b35;
  }

  .tabletop .scene-preview {
    display: grid;
    min-height: 248px;
    height: 100%;
    padding: clamp(18px, 2.5vw, 33px);
    border: 1px solid #d4c49c85;
    border-radius: 15px;
    box-shadow: inset 0 0 0 4px #15292d;
  }

  .tabletop .scene-preview::before {
    background: linear-gradient(180deg, #07141720 10%, #071417ce 76%, #071417 100%);
    opacity: 1;
  }

  .tabletop .scene-preview::after {
    display: block;
    inset: 8px;
    width: auto;
    border: 1px solid #f6e4ba67;
    border-radius: 10px;
    background: none;
    pointer-events: none;
  }

  .tabletop .scene-preview h2 {
    color: #fff3d9;
    font-size: clamp(2.15rem, 4.4vw, 4.5rem);
    letter-spacing: .05em;
  }

  .tabletop .scene-preview p {
    color: #fff3d9;
    font-size: .98rem;
  }

  .tabletop .tabletop-start {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    gap: 12px;
    min-height: 42px;
    margin-top: 14px;
    padding: 7px 13px;
    border: 1px solid #ffdea1;
    border-radius: 6px;
    background: #f4cc80;
    color: #19292a;
    font-size: .91rem;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 3px 0 #0b1618;
  }

  .tabletop .tabletop-start:hover { background: #ffdf9f; }

  .tabletop .tabletop-start:focus-visible {
    outline: 2px solid #fff3d9;
    outline-offset: 3px;
  }

  #tabletopSetup, #tabletopPlay, #debateBoardPanel, #tabletopDictionary {
    scroll-margin-top: 12px;
  }

  .tabletop .scene-emblem {
    display: none;
  }

  .tabletop .scene-badge,
  .tabletop .tabletop-coordinate {
    color: #13292c;
    background: var(--table-paper);
    border-radius: 4px;
  }

  .tabletop .tabletop-coordinate {
    position: absolute;
    top: 17px;
    right: 17px;
    padding: 5px 9px;
    font: 700 .75rem/1.4 ui-monospace, Consolas, monospace;
    letter-spacing: .1em;
  }

  .tabletop-atlas {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--table-rule);
    border-radius: 15px;
    background: #07151993;
  }

  .tabletop-atlas-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 5px 12px;
    margin: 0 0 9px;
  }

  .tabletop-atlas-heading h2 {
    margin: 0;
    color: var(--table-paper);
    font-size: 1.02rem;
  }

  .tabletop-kicker {
    display: block;
    color: #b9d6ce;
    font: 700 .69rem/1.2 ui-monospace, Consolas, monospace;
    letter-spacing: .16em;
  }

  .tabletop .scene-track {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    overflow: visible;
    padding: 0;
  }

  .tabletop .mode-card {
    min-height: 70px;
    padding: 7px 10px;
    border-color: #e9d9b54a;
    background-image: linear-gradient(105deg, #08191bed 10%, #0b2023b8 52%, #11262726),
      var(--mode-card-image, linear-gradient(135deg, var(--card-a), var(--card-b)));
    background-position: center;
    box-shadow: 0 3px 0 #0007;
    transition: transform 160ms ease, border-color 160ms ease;
  }

  .tabletop .mode-card::after { display: none; }

  .tabletop .mode-card.is-active {
    transform: none;
    outline: 1px solid #f4cc80;
    outline-offset: -3px;
    border-color: #f4cc80;
  }

  .tabletop .mode-card:hover { transform: translateY(-2px); }

  .tabletop .mode-card:focus-visible,
  .tabletop-guide summary:focus-visible {
    outline: 3px solid #f7d587;
    outline-offset: 2px;
  }

  .tabletop .mode-card-top {
    gap: 4px;
    align-items: center;
  }

  .tabletop-mode-index {
    color: #ffe3a5;
    font: 700 .75rem/1 ui-monospace, Consolas, monospace;
  }

  .tabletop .mode-track {
    padding: 2px 5px;
    border: 0;
    border-radius: 3px;
    background: #061417df;
    color: #fff5df;
    font-size: .66rem;
  }

  .tabletop .mode-card-body strong {
    color: #fff;
    font-size: 1rem;
    text-shadow: 0 1px 4px #000;
  }

  .tabletop-guide {
    grid-column: 1 / -1;
    padding: 0 13px;
    border: 1px solid var(--table-rule);
    border-radius: 14px;
    background: #07151993;
  }

  .tabletop-guide summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 58px;
    list-style: none;
    cursor: pointer;
  }

  .tabletop-guide summary::-webkit-details-marker { display: none; }
  .tabletop-guide summary::after {
    content: "";
    width: 9px;
    height: 9px;
    margin-right: 8px;
    border: solid #f3d58f;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    transition: transform 160ms ease;
  }

  .tabletop-guide[open] summary::after { transform: rotate(225deg); }

  .tabletop-guide-label {
    display: grid;
    gap: 4px;
  }

  .tabletop-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(24px, 4vw, 46px);
    margin: 0;
    padding: 3px 0 15px;
    list-style: none;
  }

  .tabletop-steps li {
    --step-paper: #f5e6c4;
    position: relative;
    padding: 10px 13px 12px;
    border: 1px solid #071519;
    border-radius: 10px;
    background: repeating-linear-gradient(0deg, transparent 0 19px, #0d202410 19px 20px), var(--step-paper);
    color: #152728;
    box-shadow: inset 0 0 0 3px #1527282b, 0 3px 0 #0009;
  }

  .tabletop-steps li:nth-child(2) { --step-paper: #d3ece0; }
  .tabletop-steps li:nth-child(3) { --step-paper: #f0d7c8; }

  .tabletop-steps li:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 50%;
    left: calc(100% + clamp(5px, 1vw, 13px));
    width: 16px;
    height: 12px;
    background: #f4cc80;
    clip-path: polygon(0 40%, 60% 40%, 60% 0, 100% 50%, 60% 100%, 60% 60%, 0 60%);
  }

  .tabletop-step-mark {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    padding-bottom: 4px;
    border-bottom: 1px solid #15272845;
    font: 800 1.3rem/1 ui-monospace, Consolas, monospace;
  }

  .tabletop-step-mark svg {
    width: 30px;
    height: 27px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linejoin: round;
    stroke-linecap: round;
  }

  .tabletop-steps strong { font-size: 1.05rem; }
  .tabletop-steps p {
    margin: 4px 0 0;
    color: #233735;
    font-size: .87rem;
    line-height: 1.55;
  }
}

@media (min-width: 980px) {
  .tabletop.stage-panel {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  }
}

@media (min-width: 561px) and (prefers-reduced-motion: no-preference) {
  .tabletop-guide[open] .tabletop-steps,
  .tabletop-steps li,
  #cardGrid .battle-card {
    animation: tabletop-deal 270ms cubic-bezier(.2, .7, .2, 1) both;
  }

  .tabletop-steps li:nth-child(2),
  #cardGrid .battle-card:nth-child(2) { animation-delay: 45ms; }
  .tabletop-steps li:nth-child(3),
  #cardGrid .battle-card:nth-child(3) { animation-delay: 90ms; }

  @keyframes tabletop-deal {
    from { opacity: .3; transform: translateY(7px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (min-width: 561px) and (prefers-reduced-motion: reduce) {
  .tabletop .mode-card,
  .tabletop-guide summary::after { transition: none; }
  .tabletop .mode-card:hover { transform: none; }
  .reel.is-spinning .reel-scene-copy,
  .reel.is-spinning .reel-scene-mark { animation: none; }
}

/* The desktop lobby and each activity have their own address and layout. */
@media (min-width: 561px) {
  body[data-desktop-view="choose"] .desktop-game,
  body[data-desktop-view="game"] .tabletop.stage-panel { display: none; }

  .desktop-game { display: grid; gap: 12px; min-width: 0; }
  .desktop-game .floating-timer {
    position: static;
    justify-self: end;
    z-index: auto;
  }

  .desktop-game > [hidden] { display: none; }

  .tabletop-game-header {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    border: 1px solid #45615f;
    border-radius: 13px;
    background: #132d30;
    color: #f8e9c9;
  }

  .tabletop-game-header h2 { margin: 0; color: inherit; font-size: clamp(1rem, 2.2vw, 1.6rem); }
  .tabletop-back, .tabletop-game-menu summary { color: #ffe0a0; font-weight: 800; }
  .tabletop-back { justify-self: start; }
  .tabletop-game-menu { justify-self: end; }
  .tabletop-game-menu summary { cursor: pointer; list-style: none; padding: 8px; }
  .tabletop-game-menu nav {
    position: absolute;
    right: 10px;
    top: calc(100% + 5px);
    display: grid;
    width: min(260px, 100%);
    max-height: 66vh;
    overflow: auto;
    padding: 8px;
    border: 1px solid #bfa16d;
    border-radius: 10px;
    background: #11292c;
    box-shadow: 0 12px 28px #09171855;
  }

  .tabletop-game-menu nav a { padding: 8px 12px; color: #f8e9c9; border-radius: 4px; text-decoration: none; }
  .tabletop-game-menu nav a:is(:hover, :focus-visible, [aria-current]) { background: #305157; }

  .desktop-game .tabletop-guide {
    color: #f7e8ca;
    background: #183438;
  }

  .tabletop .scene-preview {
    min-height: 290px;
    background: #10272a;
  }

  .tabletop .scene-preview-image {
    inset: 0 0 0 auto;
    width: 78%;
    height: 100%;
    object-fit: contain;
    object-position: right center;
    transform: none;
  }

  body:has(#imageEditorPanel) .tabletop .scene-preview-image {
    transform: translate(var(--image-x, 0), var(--image-y, 0)) rotate(var(--image-rotate, 0)) scale(var(--image-scale, 1));
  }

  .tabletop .scene-preview.has-mode-image::before {
    background: linear-gradient(90deg, #10272a 3%, #10272ad9 25%, #10272a00 66%),
      linear-gradient(0deg, #0c2022f5 0%, #0c202240 39%, transparent 60%);
  }

  .tabletop .scene-preview p { max-width: 42ch; text-shadow: 0 1px 4px #091719; }

  .tabletop-pool-summary,
  .desktop-game .history-column-head {
    min-height: 88px;
    padding: 14px 20px;
    border-radius: 9px;
    color: #faeccd;
    background: linear-gradient(90deg, #10282cf5, #10282c00 75%), var(--tabletop-board-art) right center / auto 100% no-repeat, #173237;
  }

  .tabletop-pool-summary {
    --tabletop-board-art: url("../../../assets/ui/tabletop/draw-pool.svg");
    display: grid;
    align-content: center;
    cursor: pointer;
  }
  .tabletop-pool-summary strong::after { content: " ＋"; }
  .library-band[open] .tabletop-pool-summary strong::after { content: " −"; }
  .tabletop-pool-summary .eyebrow { color: #bfe2d8; }
  .desktop-game .history-recent-column { --tabletop-board-art: url("../../../assets/ui/tabletop/memory-log.svg"); }
  .desktop-game .history-pinned-column { --tabletop-board-art: url("../../../assets/ui/tabletop/pinned-log.svg"); }
  .desktop-game .history-column-head { justify-content: flex-start; }
  .desktop-game .history-column-head h3 { color: inherit; }
  .desktop-game .history-column-head span { color: #f7dc9e; background: #10282ce6; padding: 3px 7px; border-radius: 4px; }
}

@media (min-width: 740px) {
  .tabletop.stage-panel { grid-template-columns: minmax(0, .85fr) minmax(0, 1.4fr); }
  .tabletop .scene-preview { min-height: 360px; }
}
