:root {
  --bg: #08120f;
  --panel: #14362a;
  --panel-strong: #0d251c;
  --panel-soft: rgba(20, 54, 42, 0.88);
  --ink: #f7f1e3;
  --muted: #b6caba;
  --accent: #ffcf56;
  --accent-strong: #ff9e3d;
  --danger: #ff6b5f;
  --good: #74d99f;
  --line: rgba(247, 241, 227, 0.12);
  --shadow: 0 24px 55px rgba(0, 0, 0, 0.3);
  --radius: 22px;
  --font-head: Georgia, "Times New Roman", serif;
  --font-body: "Trebuchet MS", Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 207, 86, 0.12), transparent 28%),
    linear-gradient(180deg, #102820 0%, #08120f 100%);
  color: var(--ink);
  font-family: var(--font-body);
}

body {
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.hero {
  padding: 22px 20px 10px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.4rem);
  font-family: var(--font-head);
}

.hero-copy {
  margin: 12px 0 0;
  max-width: 42rem;
  color: var(--muted);
  line-height: 1.5;
}

.app {
  display: grid;
  gap: 16px;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-title {
  margin: 0 0 8px;
  font-size: 1.18rem;
  font-family: var(--font-head);
}

.panel-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.menu-hero {
  padding: 24px;
}

.menu-title {
  font-size: clamp(1.9rem, 5vw, 3rem);
}

.menu-grid,
.setup-grid,
.score-grid,
.meta-grid,
.summary-grid {
  display: grid;
  gap: 12px;
}

.menu-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.setup-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.score-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.meta-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.rank-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.menu-card {
  padding: 18px;
}

.menu-card h3 {
  margin: 0;
  font-size: 1.1rem;
  font-family: var(--font-head);
}

.menu-card-active {
  background:
    linear-gradient(180deg, rgba(255, 207, 86, 0.09), transparent),
    var(--panel);
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.92rem;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(8, 18, 15, 0.72);
}

.stack {
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.spread {
  justify-content: space-between;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.92rem;
}

.team-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(8, 18, 15, 0.4);
}

.team-card h3,
.seat-info h3,
.viewer-prompt h3 {
  margin: 0;
  font-size: 1.05rem;
}

.rank-line {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.rank-match-line {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rank-match-line:last-child {
  border-bottom: 0;
}

.rank-list {
  display: grid;
  gap: 6px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 64px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--rank-bg);
  color: var(--rank-fg);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 8px 22px rgba(0, 0, 0, 0.22);
  border: 2px solid var(--rank-ring);
}

.rank-badge.small {
  min-width: 48px;
  height: 48px;
  font-size: 0.66rem;
}

.rank-badge.spade-master {
  min-width: 68px;
  height: 70px;
  border-radius: 0;
  clip-path: polygon(50% 0%, 72% 18%, 94% 38%, 84% 60%, 66% 67%, 60% 74%, 60% 100%, 40% 100%, 40% 74%, 34% 67%, 16% 60%, 6% 38%, 28% 18%);
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.18), transparent 28%),
    linear-gradient(180deg, #212121, #050505);
  color: #f4d89a;
  border-color: #be9f56;
}

.team-stat-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.team-stat {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.team-stat span {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}

.team-stat strong {
  display: block;
  font-size: 1.1rem;
  color: var(--accent);
}

.button {
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #1d1608;
  font-weight: 700;
  cursor: pointer;
}

.button.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

.button.danger {
  background: var(--danger);
  color: #fff;
}

.button.active-view {
  box-shadow: inset 0 0 0 1px rgba(255, 207, 86, 0.6);
}

.button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.callout {
  border-left: 4px solid var(--accent);
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 207, 86, 0.08);
  color: var(--ink);
}

.callout.good {
  border-left-color: var(--good);
  background: rgba(116, 217, 159, 0.08);
}

.callout.danger {
  border-left-color: var(--danger);
  background: rgba(255, 107, 95, 0.08);
}

.rule-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rule-list li {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.tutorial-card-strip,
.tutorial-trick-line,
.tutorial-trick-board,
.tutorial-arrow-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.tutorial-card {
  min-width: 92px;
  padding: 12px 10px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 248, 231, 0.98), rgba(244, 233, 204, 0.96));
  color: #2a1a0a;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
}

.tutorial-card strong {
  font-size: 1.2rem;
}

.tutorial-card span {
  font-size: 0.76rem;
  line-height: 1.3;
}

.tutorial-card-top {
  outline: 2px solid rgba(255, 194, 67, 0.42);
}

.tutorial-card-muted {
  background:
    linear-gradient(180deg, rgba(244, 244, 239, 0.96), rgba(219, 220, 214, 0.96));
  color: #364038;
}

.tutorial-card-danger {
  background:
    linear-gradient(180deg, rgba(255, 233, 228, 0.98), rgba(246, 200, 191, 0.96));
  color: #5f1f16;
}

.tutorial-trick-board {
  justify-content: space-between;
}

.tutorial-seat,
.tutorial-mini-panel {
  flex: 1 1 140px;
  min-width: 0;
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.tutorial-mini-panel strong {
  color: var(--ink);
}

.tutorial-mini-panel span {
  color: var(--muted);
  font-size: 0.9rem;
}

.tutorial-arrow {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.special-name {
  color: #c88cff;
  text-shadow:
    0 0 12px rgba(155, 87, 255, 0.28),
    0 2px 10px rgba(0, 0, 0, 0.24);
}

.table-panel {
  padding: 18px;
}

.table-stage {
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15), transparent);
}

.table-surface {
  position: relative;
  min-height: 780px;
  padding: 18px;
  display: grid;
  grid-template-columns: 170px 1fr 170px;
  grid-template-rows: 160px 1fr 280px;
  grid-template-areas:
    "top top top"
    "left center right"
    "bottom bottom bottom";
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.08), transparent 30%),
    radial-gradient(circle at center, rgba(9, 38, 24, 0.18), transparent 58%),
    linear-gradient(180deg, rgba(27, 104, 61, 0.96), rgba(11, 56, 34, 0.98)),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.02) 0,
      rgba(255, 255, 255, 0.02) 3px,
      rgba(0, 0, 0, 0.03) 3px,
      rgba(0, 0, 0, 0.03) 6px
    );
}

.seat {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seat-top {
  grid-area: top;
  flex-direction: column;
  gap: 8px;
  align-content: start;
}

.seat-left {
  grid-area: left;
  flex-direction: column;
  gap: 10px;
  align-content: center;
}

.seat-center {
  grid-area: center;
}

.seat-right {
  grid-area: right;
  flex-direction: column;
  gap: 10px;
  align-content: center;
}

.seat-bottom {
  grid-area: bottom;
  display: grid;
  gap: 14px;
  align-content: end;
  padding-bottom: 12px;
}

.seat-info {
  text-align: center;
  color: #f8e9d3;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.seat-info p,
.viewer-header p,
.viewer-prompt p {
  margin: 4px 0 0;
  color: rgba(255, 244, 224, 0.82);
}

.pot-area {
  width: min(100%, 500px);
  margin: 0 auto;
  padding: 18px;
  border-radius: 30px;
  background: radial-gradient(circle, rgba(25, 70, 46, 0.85), rgba(11, 31, 22, 0.95));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 24px 55px rgba(0, 0, 0, 0.28);
}

.pot-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: rgba(255, 244, 224, 0.9);
}

.pot-label span {
  color: rgba(255, 244, 224, 0.72);
  font-size: 0.88rem;
}

.pot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 110px 110px 110px;
  gap: 6px;
  grid-template-areas:
    ". top ."
    "left center right"
    ". bottom .";
  place-items: center;
}

.pot-top {
  grid-area: top;
}

.pot-left {
  grid-area: left;
}

.pot-right {
  grid-area: right;
}

.pot-bottom {
  grid-area: bottom;
}

.pot-empty {
  width: 76px;
  height: 106px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  color: rgba(255, 244, 224, 0.56);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff3df;
}

.viewer-prompt {
  min-height: 180px;
  padding: 20px;
  border-radius: 22px;
  background: rgba(8, 18, 15, 0.28);
  border: 1px dashed rgba(255, 255, 255, 0.22);
  text-align: center;
  display: grid;
  place-items: center;
}

.fan-hand {
  position: relative;
  height: 190px;
  width: min(100%, 900px);
  margin: 0 auto;
}

.fan-card {
  position: absolute;
  left: calc(50% + var(--fan-offset));
  bottom: 0;
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(var(--fan-rotation));
}

.fan-card.static {
  pointer-events: none;
}

.card-button {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.card-face {
  width: 92px;
  min-height: 124px;
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(180deg, #fff9ea, #ece1c6);
  color: #2b2411;
  display: grid;
  align-content: space-between;
  box-shadow:
    inset 0 0 0 1px rgba(43, 36, 17, 0.12),
    0 14px 26px rgba(0, 0, 0, 0.2);
}

.card-face.red {
  color: #7a1e1b;
}

.card-face.small {
  width: 76px;
  min-height: 104px;
  padding: 10px;
}

.card-corner {
  font-weight: 700;
  font-size: 1rem;
}

.card-name {
  font-size: 0.95rem;
  font-family: var(--font-head);
}

.card-button .card-face {
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.card-button:hover .card-face,
.card-button:focus-visible .card-face {
  transform: translateY(-6px);
}

.card-button.selected .card-face {
  transform: translateY(-6px);
  box-shadow:
    inset 0 0 0 2px rgba(255, 207, 86, 0.75),
    0 20px 34px rgba(0, 0, 0, 0.28);
}

.card-button.disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.back-stack {
  position: relative;
  width: 74px;
  height: 108px;
}

.card-back {
  position: absolute;
  inset: 0;
  transform: translate(calc(var(--stack-index) * 3px), calc(var(--stack-index) * -2px));
  border-radius: 16px;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.12),
      rgba(255, 255, 255, 0.12) 6px,
      rgba(0, 0, 0, 0.08) 6px,
      rgba(0, 0, 0, 0.08) 12px
    ),
    linear-gradient(180deg, #f3d17d, #b8792d);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.18),
    0 10px 18px rgba(0, 0, 0, 0.18);
}

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

.overlay-card {
  width: min(100%, 440px);
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent), var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.overlay-card h2 {
  margin: 0 0 10px;
  font-size: 1.55rem;
  font-family: var(--font-head);
}

.overlay-card p {
  color: var(--muted);
  line-height: 1.45;
}

.danger-pill {
  background: rgba(214, 84, 84, 0.22);
  color: #ffd7d7;
  border: 1px solid rgba(255, 163, 163, 0.35);
}

@media (max-width: 960px) {
  .table-surface {
    min-height: 700px;
    grid-template-columns: 130px 1fr 130px;
    grid-template-rows: 130px 1fr 245px;
  }

  .fan-hand {
    width: min(100%, 720px);
    height: 178px;
  }

  .fan-card {
    left: min(var(--fan-offset), calc(100% - 90px));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px 12px 36px;
  }

  .hero {
    padding: 12px 8px 6px;
  }

  .panel {
    padding: 14px;
  }

  .table-surface {
    min-height: 610px;
    padding: 12px;
    grid-template-columns: 82px 1fr 82px;
    grid-template-rows: 104px 1fr 220px;
  }

  .fan-hand {
    height: 168px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
  }

  .fan-card {
    position: relative;
    left: auto;
    display: inline-block;
    margin-right: -36px;
    transform: rotate(calc(var(--fan-rotation) * 0.35));
  }

  .card-face {
    width: 76px;
    min-height: 108px;
    padding: 10px;
  }

  .card-face.small {
    width: 66px;
    min-height: 92px;
  }

  .pot-area {
    padding: 12px;
  }
}
