:root {
  --cream: #f7e8c2;
  --gold: #d6a958;
  --gold-light: #f1d18a;
  --navy: #0c293b;
  --navy-light: #173f58;
  --wood: #5c351d;
  --wood-dark: #28170e;
  --felt: #173f2d;
  --felt-light: #285c43;
  --red: #9e2528;
  --card-w: clamp(48px, 5.35vw, 82px);
  --card-h: calc(var(--card-w) * 1.42);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--cream);
  background: #120c08;
  font-family: Georgia, "Times New Roman", serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  min-height: 100vh;
}

.game-room {
  position: relative;
  width: min(100vw, 1664px);
  aspect-ratio: 1664 / 960;
  min-height: 760px;
  margin: 0 auto;
  overflow: hidden;
  background: #1c120b;
}

.room-backdrop {
  position: absolute;
  inset: 0;
  background-image: url("../assets/promise-harbor-card-room-background.png");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.room-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 48%, transparent 0 52%, rgba(13,8,5,.25) 86%, rgba(13,8,5,.58) 100%);
}

.accessible-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.menu-hotspot {
  position: absolute;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}
.menu-hotspot:not(:disabled):hover,
.menu-hotspot:not(:disabled):focus-visible {
  border-color: rgba(246, 205, 112, .95);
  box-shadow: 0 0 18px rgba(246, 205, 112, .65), inset 0 0 16px rgba(246, 205, 112, .14);
}
.menu-hotspot:disabled { cursor: default; }

.left-menu .active { left: 3.0%; top: 28.0%; width: 15.2%; height: 10.4%; }
.left-menu .board { left: 3.0%; top: 39.3%; width: 15.2%; height: 9.8%; }
.left-menu .puzzles { left: 3.0%; top: 50.3%; width: 15.2%; height: 9.8%; }

.right-menu .coloring { right: 3.0%; top: 28.0%; width: 15.2%; height: 9.8%; }
.right-menu .achievements { right: 3.0%; top: 39.3%; width: 15.2%; height: 9.8%; }
.right-menu .stories { right: 3.0%; top: 50.3%; width: 15.2%; height: 9.8%; }

.functional-table {
  position: absolute;
  left: 20.9%;
  top: 34.2%;
  width: 58.4%;
  height: 49.8%;
  padding: 1.6% 4.5% 1.8%;
  border: 4px solid rgba(122, 76, 39, .88);
  border-radius: 13% 13% 8% 8% / 10% 10% 7% 7%;
  background:
    radial-gradient(circle at center, rgba(255,255,255,.035), transparent 58%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.018) 0 12px, transparent 12px 24px),
    linear-gradient(145deg, rgba(39,91,66,.985), rgba(19,58,42,.985));
  box-shadow:
    0 14px 22px rgba(0,0,0,.38),
    inset 0 0 0 2px rgba(214,169,88,.55),
    inset 0 0 34px rgba(0,0,0,.38);
  display: grid;
  grid-template-rows: auto 104px 1px auto;
  gap: 10px;
}

.opponent-zone,
.player-zone {
  min-height: 0;
}

.zone-heading {
  margin: 0 0 5px;
  color: var(--cream);
  text-align: center;
  font-size: clamp(.62rem, .98vw, .92rem);
  font-weight: 700;
  text-transform: uppercase;
  text-shadow: 0 2px 3px rgba(0,0,0,.6);
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: .7%;
}

.numbered-slot {
  position: relative;
  min-width: 0;
}

.slot-card-area {
  width: 100%;
  aspect-ratio: 1 / 1.42;
  min-height: 0;
  border: 1px solid rgba(226, 205, 148, .5);
  border-radius: 5px;
  background:
    linear-gradient(rgba(255,255,255,.02), rgba(255,255,255,.02)),
    rgba(4, 34, 24, .28);
}

.opponent-grid .slot-card-area::before {
  content: "⚓";
  display: grid;
  place-items: center;
  height: 100%;
  color: rgba(225,204,145,.11);
  font-size: clamp(.8rem, 1.5vw, 1.35rem);
}

.slot-number {
  display: block;
  margin-top: 2px;
  text-align: center;
  color: var(--cream);
  font-size: clamp(.47rem, .76vw, .7rem);
  font-weight: 700;
}

.center-play-zone {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  align-items: center;
  gap: clamp(42px, 6vw, 88px);
  min-height: 104px;
}

.pile-section {
  display: grid;
  justify-items: center;
  align-content: center;
}

.pile-title {
  margin-bottom: 5px;
  color: var(--cream);
  font-size: clamp(.58rem, .9vw, .86rem);
  font-weight: 700;
  text-transform: uppercase;
  text-shadow: 0 2px 3px rgba(0,0,0,.6);
}

/* Physical piles are turned 90 degrees into landscape orientation. */
.center-play-zone .pile-holder {
  display: grid;
  place-items: center;
  width: var(--card-h);
  height: var(--card-w);
  padding: 0;
  border: 1px solid rgba(238, 211, 143, .58);
  border-radius: 6px;
  background: rgba(7, 35, 25, .34);
  overflow: visible;
}

.center-play-zone .pile-holder > .card {
  width: var(--card-w);
  height: var(--card-h);
  transform: rotate(90deg);
  transform-origin: center;
}

.center-play-zone .pile-holder > .card:hover,
.center-play-zone .pile-holder > .card:focus-visible {
  transform: rotate(90deg) scale(1.035);
}

.empty-holder {
  border-style: dashed;
}

.pile-count {
  margin-top: 5px;
  font-size: clamp(.48rem, .75vw, .72rem);
}

.table-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: rgba(239,208,132,.82);
}

.table-divider span {
  flex: 1;
  height: 1px;
  background: rgba(239,208,132,.5);
}

.table-controls {
  position: absolute;
  left: 25.8%;
  top: 86.2%;
  width: 48.4%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 2.2%;
}

.table-controls button {
  min-height: 42px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--gold-light);
  background: linear-gradient(#163c54, #0b2638);
  box-shadow: 0 5px 11px rgba(0,0,0,.38), inset 0 0 0 1px rgba(255,255,255,.08);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.table-controls button:hover,
.table-controls button:focus-visible {
  filter: brightness(1.14);
  box-shadow: 0 0 15px rgba(231,188,93,.45);
}

.card {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid rgba(0,0,0,.3);
  border-radius: 5px;
  overflow: hidden;
  color: #151515;
  background: #fff8e7;
  box-shadow: 0 4px 8px rgba(0,0,0,.28);
}

.card.red { color: var(--red); }

.card-back {
  display: grid;
  place-content: center;
  gap: 3px;
  color: var(--gold-light);
  border: 4px double var(--gold);
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.045) 0 7px, transparent 7px 14px),
    linear-gradient(#153e59, #0b283c);
  text-align: center;
}

.back-mark { font-size: clamp(1rem, 2.1vw, 1.8rem); }
.back-title {
  font-size: clamp(.42rem, .65vw, .62rem);
  font-weight: 700;
  letter-spacing: .05em;
}

.corner {
  position: absolute;
  display: grid;
  justify-items: center;
  line-height: .9;
  font-weight: 700;
  font-size: clamp(.46rem, .72vw, .7rem);
}
.corner-top { top: 3px; left: 3px; }
.corner-bottom { right: 3px; bottom: 3px; transform: rotate(180deg); }

.center-art {
  position: absolute;
  inset: 24% 15% 31%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(11,41,59,.05);
  font-size: clamp(1rem, 2vw, 1.8rem);
}

.card-caption {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 16%;
  color: #3f4b51;
  font-size: clamp(.34rem, .53vw, .5rem);
  line-height: 1;
  text-align: center;
}

.empty-label {
  color: rgba(255,255,255,.5);
  font-size: clamp(.4rem, .62vw, .58rem);
  text-align: center;
}

.game-options {
  position: absolute;
  left: 1.7%;
  bottom: 3.6%;
  width: 15%;
  padding: 1% 1.2%;
  border: 1px solid var(--gold);
  border-radius: 7px;
  color: var(--cream);
  background: rgba(6, 32, 46, .94);
  box-shadow: 0 7px 18px rgba(0,0,0,.38);
}

.game-options h2 {
  margin: 0 0 8px;
  font-size: clamp(.62rem, .95vw, .9rem);
  text-align: center;
  text-transform: uppercase;
}

.game-options label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  margin: 6px 0;
  font-size: clamp(.5rem, .75vw, .72rem);
}

.game-options input {
  width: 20px;
  height: 20px;
  accent-color: var(--gold);
}

.status-message {
  position: absolute;
  left: 36%;
  right: 36%;
  bottom: .6%;
  padding: 5px 10px;
  border-radius: 5px;
  color: rgba(247,232,194,.86);
  background: rgba(18,11,7,.68);
  text-align: center;
  font-size: clamp(.45rem, .68vw, .64rem);
}

dialog {
  width: min(500px, calc(100% - 24px));
  padding: 0;
  border: 1px solid var(--gold);
  border-radius: 12px;
  color: var(--cream);
  background: #0b293b;
  box-shadow: 0 18px 40px rgba(0,0,0,.5);
}

dialog::backdrop { background: rgba(0,0,0,.72); }

.settings-dialog {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.settings-dialog header,
.settings-dialog label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-dialog header p,
.settings-dialog header h2 { margin: 0; }

.settings-dialog header p {
  color: var(--gold-light);
  font-size: .76rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.settings-dialog header button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--cream);
  background: transparent;
}

.settings-dialog label {
  padding: 11px 0;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.settings-dialog input {
  width: 24px;
  height: 24px;
  accent-color: var(--gold);
}

.done-button {
  min-height: 44px;
  border: 1px solid var(--gold);
  border-radius: 7px;
  color: var(--gold-light);
  background: linear-gradient(#173f58, #0b293b);
  font-weight: 700;
}

@media (max-width: 900px) {
  .game-room {
    width: 100%;
    min-height: 100vh;
    aspect-ratio: auto;
    overflow-y: auto;
    background: #24160d;
  }

  .room-backdrop {
    position: fixed;
    background-size: auto 100vh;
    background-position: center top;
    opacity: .68;
  }

  .functional-table {
    position: relative;
    left: auto;
    top: auto;
    width: calc(100% - 20px);
    height: auto;
    min-height: 690px;
    margin: 42vh auto 110px;
    padding: 20px 16px 90px;
    border-radius: 24px;
  }

  .table-header-row { height: 180px; }
  .slot-grid { grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; }
  .table-divider { margin: 12px 0 8px; }
    .table-controls {
    left: 16px;
    right: 16px;
    bottom: 16px;
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .game-options {
    position: fixed;
    left: 10px;
    bottom: 10px;
    z-index: 5;
    width: min(260px, calc(100% - 20px));
    padding: 10px 12px;
  }

  .status-message {
    position: fixed;
    left: auto;
    right: 10px;
    bottom: 10px;
    width: min(250px, 44vw);
    z-index: 5;
  }

  .left-menu,
  .right-menu { display: none; }
}

@media (max-width: 600px) {
  :root { --card-w: 62px; }
  .functional-table { margin-top: 34vh; }
  .status-message { display: none; }
  .game-options { width: calc(100% - 20px); }
}


/* Card art inspection */
.face-card:not(:disabled),
.slot-card-area .face-card {
  cursor: zoom-in;
}

.slot-card-area .face-card:hover,
.slot-card-area .face-card:focus-visible,
.drawn-card-holder .face-card:hover,
.drawn-card-holder .face-card:focus-visible,
.pile-holder .face-card:hover,
.pile-holder .face-card:focus-visible {
  transform: translateY(-4px) scale(1.035);
  box-shadow: 0 10px 18px rgba(0,0,0,.42), 0 0 0 2px rgba(242,204,112,.68);
  z-index: 4;
}

.card {
  transition: transform .16s ease, box-shadow .16s ease;
}

.card-viewer-dialog {
  width: min(860px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--gold);
  border-radius: 16px;
  color: var(--cream);
  background:
    radial-gradient(circle at 25% 35%, rgba(255,255,255,.06), transparent 45%),
    linear-gradient(145deg, #153b51, #081f2e);
  box-shadow: 0 24px 60px rgba(0,0,0,.62);
}

.card-viewer-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(250px, 390px) 1fr;
  gap: 28px;
  align-items: center;
  padding: 34px;
}

.card-viewer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--cream);
  background: rgba(4,20,30,.72);
  z-index: 3;
}

.card-viewer-card {
  width: min(100%, 360px);
  aspect-ratio: 1 / 1.42;
  margin: 0 auto;
}

.card-viewer-card .card {
  cursor: default;
  border-radius: 15px;
  box-shadow: 0 20px 38px rgba(0,0,0,.46);
}

.card-viewer-card .corner {
  font-size: clamp(1.35rem, 3vw, 2.3rem);
}

.card-viewer-card .corner-top {
  top: 14px;
  left: 14px;
}

.card-viewer-card .corner-bottom {
  right: 14px;
  bottom: 14px;
}

.card-viewer-card .center-art {
  font-size: clamp(4rem, 9vw, 7.5rem);
}

.card-viewer-card .card-caption {
  bottom: 14%;
  font-size: clamp(.9rem, 1.8vw, 1.35rem);
}

.card-viewer-copy {
  padding-right: 12px;
}

.card-viewer-eyebrow {
  margin: 0 0 8px;
  color: var(--gold-light);
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.card-viewer-copy h2 {
  margin: 0 0 12px;
  font-size: clamp(1.7rem, 4vw, 2.8rem);
}

.card-viewer-copy p:last-child {
  margin: 0;
  color: rgba(255,255,255,.78);
  line-height: 1.6;
}

@media (max-width: 900px) {
  .table-controls {
    position: relative;
    left: auto;
    top: auto;
    width: calc(100% - 20px);
    margin: -92px auto 120px;
    padding: 0 16px;
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .functional-table {
    padding-bottom: 28px;
    margin-bottom: 0;
  }

  .card-viewer-shell {
    grid-template-columns: 1fr;
    padding: 28px 20px 24px;
  }

  .card-viewer-card {
    width: min(72vw, 330px);
  }

  .card-viewer-copy {
    text-align: center;
    padding-right: 0;
  }
}








@media (max-width: 900px) {
  .functional-table {
    min-height: 820px;
    padding-top: 22px;
  }

  .table-header-row {
    height: 205px;
    min-height: 205px;
  }

  
  .table-controls {
    margin-top: -102px;
  }
}

@media (max-width: 900px) {
  .functional-table {
    position: relative;
    left: auto;
    top: auto;
    width: calc(100% - 20px);
    height: auto;
    min-height: 820px;
    margin: 40vh auto 0;
    padding: 20px 14px 26px;
    grid-template-rows: auto auto auto auto;
    gap: 18px;
  }

  .slot-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: auto;
    gap: 8px;
  }

  .slot-card-area {
    height: auto;
    aspect-ratio: 1 / 1.42;
  }

  .center-play-zone {
    grid-template-columns: repeat(3, auto);
    gap: 16px;
  }

  .table-controls {
    position: relative;
    left: auto;
    top: auto;
    width: calc(100% - 20px);
    margin: 12px auto 120px;
    padding: 0 16px;
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}

@media (max-width: 560px) {
  .center-play-zone {
    gap: 9px;
  }
}


@media (max-width: 900px) {
  .functional-table {
    position: relative;
    left: auto;
    top: auto;
    width: calc(100% - 20px);
    height: auto;
    min-height: 780px;
    margin: 40vh auto 0;
    padding: 20px 14px 28px;
    grid-template-rows: auto 110px 1px auto;
    gap: 16px;
  }

  .slot-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  .center-play-zone {
    grid-template-columns: auto auto;
    gap: 34px;
  }

  .table-controls {
    position: relative;
    left: auto;
    top: auto;
    width: calc(100% - 20px);
    margin: 12px auto 120px;
    padding: 0 16px;
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}


/* PHASE 2 — TRASH GAMEPLAY */
.numbered-slot {
  cursor: default;
  transition: filter .16s ease, transform .16s ease;
}

.numbered-slot.valid-target {
  cursor: pointer;
  transform: translateY(-3px);
}

.numbered-slot.valid-target .slot-card-area {
  border: 2px solid #f5d67f;
  box-shadow:
    0 0 0 2px rgba(245,214,127,.22),
    0 0 18px rgba(245,214,127,.72),
    inset 0 0 14px rgba(245,214,127,.12);
}

.numbered-slot.valid-target:hover {
  filter: brightness(1.16);
}

.numbered-slot.filled-slot .slot-card-area {
  border-color: rgba(245,214,127,.72);
}

.discard-clickable {
  cursor: pointer;
  box-shadow: 0 0 14px rgba(245,214,127,.38);
}

.active-card-holder {
  border-color: #f5d67f !important;
  box-shadow: 0 0 20px rgba(245,214,127,.72);
}

.active-card-holder::after {
  content: "PLAY";
  position: absolute;
  right: -4px;
  bottom: -5px;
  padding: 2px 5px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--navy);
  background: var(--gold-light);
  font-size: .48rem;
  font-weight: 700;
  transform: rotate(-90deg);
}

.center-play-zone .pile-holder {
  position: relative;
}

.opponent-grid .card-back,
.player-grid .card-back {
  width: 100%;
  height: 100%;
}

@media (max-width: 900px) {
  .numbered-slot.valid-target {
    transform: none;
  }
}


/* Phase 2 uses only the draw and discard piles in the center. */
.center-play-zone {
  grid-template-columns: auto auto !important;
}
.drawn-card-section,
.drawn-card-holder,
.drawn-card-row {
  display: none !important;
}


/* FIX: keep every dealt card inside its assigned numbered slot */
.slot-card-area {
  position: relative;
  overflow: hidden;
}

.opponent-grid .slot-card-area::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.slot-card-area > .card,
.slot-card-area > .card-back {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
}

.slot-card-area > .card:hover,
.slot-card-area > .card:focus-visible {
  z-index: 2;
}

/* Do not let card hover movement escape its assigned slot. */
.slot-card-area .card:hover,
.slot-card-area .card:focus-visible {
  transform: none;
}


/* PROMISE HARBOR PRODUCTION DECK — V1 */
.face-card {
  border: 2px solid #c9a75c;
  background:
    radial-gradient(circle at 50% 42%, rgba(218,181,100,.11), transparent 38%),
    linear-gradient(145deg, #fffef9 0%, #f5ecd8 100%);
  box-shadow: 0 4px 9px rgba(0,0,0,.3), inset 0 0 0 2px rgba(255,255,255,.72);
}

.face-card::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(17,49,67,.22);
  border-radius: 3px;
  pointer-events: none;
}

.center-art {
  inset: 17% 17% 23%;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.center-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: saturate(.9) contrast(1.04);
  opacity: .92;
}

.face-card.red .center-art img {
  filter: saturate(.88) contrast(1.04);
}

.corner {
  z-index: 2;
  gap: 1px;
  line-height: .78;
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
}

.corner .rank {
  font-size: 1.08em;
}

.corner .suit {
  font-size: 1.03em;
}

.card-caption {
  z-index: 2;
  bottom: 7%;
  color: #17384d;
  font-weight: 700;
  letter-spacing: .02em;
  text-shadow: 0 1px 0 rgba(255,255,255,.9);
}

.card-back {
  position: relative;
  padding: 5%;
  border: 4px double #d6a958;
  background:
    radial-gradient(circle at center, rgba(255,255,255,.08), transparent 42%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.035) 0 7px, transparent 7px 14px),
    linear-gradient(145deg, #154c6a, #071f31);
}

.card-back::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(241,209,138,.75);
  border-radius: 2px;
}

.back-logo {
  position: relative;
  z-index: 1;
  display: block;
  width: 82%;
  max-height: 88%;
  margin: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.5));
}

.card-viewer-card .center-art {
  inset: 15% 16% 21%;
}

.card-viewer-card .card-caption {
  bottom: 7%;
}

.card-viewer-card .center-art img {
  opacity: 1;
}
