/* ===== AI Property Tycoon — Claymorphic Pastel ===== */

:root {
  --page-bg: #f5f1e8;
  --surface: #fffdf8;
  --text: #352f2a;
  --muted: #8c8175;
  --coral: #e87455;
  --mint: #8dbd98;
  --aqua: #7eb5d5;
  --lavender: #a989c3;

  /* Legacy aliases (used by board / panels) */
  --cream: var(--page-bg);
  --cream-2: var(--surface);
  --sand: #eee6d8;
  --ink: var(--text);
  --ink-soft: #4a423b;
  --peach: #f0916e;
  --peach-soft: #ffe2d4;
  --mint-soft: #d8eee0;
  --sky: var(--aqua);
  --sky-soft: #d9eef8;
  --lavender-soft: #ebe0f4;
  --teal: #5ec4c0;
  --gold: #f0c85a;
  --gold-soft: #ffe8b0;
  --green: #5cbf8a;
  --red: #e86a6a;
  --white: #ffffff;
  --shadow: 0 14px 32px rgba(120, 95, 70, 0.12);
  --shadow-sm: 0 6px 16px rgba(120, 95, 70, 0.1);
  --shadow-inset: inset 0 2px 0 rgba(255, 255, 255, 0.92), inset 0 -4px 12px rgba(180, 130, 90, 0.05);
  --radius-panel: 24px;
  --radius-card: 18px;
  --radius-pill: 999px;
  --display: "Nunito", "Fredoka", "Noto Sans SC", sans-serif;
  --body: "Nunito", "Fredoka", "Noto Sans SC", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html,
body { margin: 0; min-height: 100%; }

body.clay-tycoon {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--body);
  font-weight: 600;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 255, 255, 0.7), transparent 55%),
    radial-gradient(circle at 12% 88%, rgba(232, 200, 170, 0.18), transparent 28%),
    radial-gradient(circle at 90% 20%, rgba(200, 220, 200, 0.14), transparent 24%),
    var(--page-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
a { font: inherit; }

/* Global content shell — aligns header + 3-column layout */
.tycoon-shell {
  width: min(1680px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 0.85rem 0 1.5rem;
  display: grid;
  gap: 0.85rem;
}

/* ===== Clay surface ===== */
.clay-surface {
  background: var(--surface);
  border: none;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm), var(--shadow-inset);
}

/* ===== Floating Header ===== */
.game-header {
  min-height: 68px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
  padding: 0.7rem 1.15rem;
  background: var(--surface);
  border: none;
  border-radius: 24px;
  box-shadow:
    0 10px 28px rgba(120, 95, 70, 0.1),
    0 2px 0 rgba(255, 255, 255, 0.85) inset;
  position: sticky;
  top: 0.7rem;
  z-index: 40;
}

.home-link {
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
  transition: color 0.15s ease, opacity 0.15s ease;
}
.home-link:hover {
  color: var(--coral);
}

.game-title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  justify-self: center;
}
.title-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 16px;
  background:
    radial-gradient(circle at 35% 28%, #fff, transparent 48%),
    linear-gradient(160deg, #fff8ef, #efe4d4);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 4px 0 #e0d4c4,
    0 8px 14px rgba(120, 95, 70, 0.12);
  overflow: hidden;
}
.title-icon {
  width: 86%;
  height: 86%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 1px 1px rgba(100, 70, 40, 0.12));
}
.game-title-copy strong {
  display: block;
  font: 800 1.05rem/1.15 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.game-title-copy small {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.header-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-button {
  border: none;
  border-radius: 14px;
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 4px 12px rgba(120, 95, 70, 0.1);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}
.header-button:hover {
  filter: brightness(1.02);
  transform: translateY(-1px);
}
.header-button.rules-btn {
  background: #fff;
  color: var(--text);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 5px 14px rgba(120, 95, 70, 0.1);
}
.header-button.match-mode {
  color: #fff;
  background: var(--coral);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.28) inset,
    0 5px 14px rgba(232, 116, 85, 0.32);
}
.header-button.match-mode:hover {
  filter: brightness(1.04);
}

.lang-host { display: flex; align-items: center; }

/* Language toggle — coral active chip (logic unchanged) */
.clay-tycoon .lang-toggle {
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: #ece7df;
  box-shadow: none;
}
.clay-tycoon .lang-toggle .lang-btn {
  min-width: 2.15rem;
  height: 1.75rem;
  border-radius: 11px;
  color: var(--text);
  background: transparent;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.72rem;
  box-shadow: none;
}
.clay-tycoon .lang-toggle .lang-btn:hover {
  background: rgba(255, 255, 255, 0.45);
}
.clay-tycoon .lang-toggle .lang-btn.is-on {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 2px 6px rgba(232, 116, 85, 0.28);
}

/* ===== Layout: left sidebar + board + right sidebar ===== */
.game-layout {
  width: 100%;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(200px, 250px) minmax(0, 1fr) minmax(220px, 270px);
  gap: 0.85rem;
  align-items: stretch;
}

/* ===== Left gameplay panel ===== */
.status-panel { display: grid; gap: 0.75rem; }

.player-card,
.turn-card,
.legend-card {
  background: var(--surface);
  border: none;
  border-radius: 22px;
  box-shadow:
    0 8px 20px rgba(120, 95, 70, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

/* ===== Player cards ===== */
.player-card {
  padding: 0.85rem 0.9rem 0.85rem 1rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.player-card::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 0;
  width: 4px;
  border-radius: 999px;
  background: var(--coral);
}
.player-card.player-bot::before {
  background: var(--aqua);
}
.player-card.is-active {
  box-shadow:
    0 10px 24px rgba(120, 95, 70, 0.12),
    0 0 0 2px color-mix(in srgb, var(--coral) 28%, transparent),
    0 1px 0 rgba(255, 255, 255, 0.9) inset;
}
.player-card.player-bot.is-active {
  box-shadow:
    0 10px 24px rgba(120, 95, 70, 0.12),
    0 0 0 2px color-mix(in srgb, var(--aqua) 35%, transparent),
    0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.player-card-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: center;
}
.avatar {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 1.55rem;
  line-height: 1;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 4px 0 rgba(0, 0, 0, 0.06),
    0 8px 14px rgba(90, 70, 50, 0.1);
}
.avatar-you {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.9), transparent 45%),
    linear-gradient(145deg, #d8c8ff, #9a78e8);
}
.avatar-bot {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.9), transparent 45%),
    linear-gradient(145deg, #ffd0e0, #f090b0);
}

.player-meta { min-width: 0; }
.player-label-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.player-label-row strong {
  font: 800 0.82rem/1.2 var(--display);
  color: var(--text);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.status-chip {
  display: inline-grid;
  place-items: center;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  background: #efe8de;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.player-card.is-active .status-chip {
  background: color-mix(in srgb, var(--coral) 18%, #fff);
  color: var(--coral);
}
.player-card.player-bot.is-active .status-chip {
  background: color-mix(in srgb, var(--aqua) 22%, #fff);
  color: #4a88a8;
}

.money {
  margin: 0.28rem 0 0.12rem;
  font: 800 1.55rem/1 var(--display);
  color: var(--mint);
  letter-spacing: -0.02em;
}
.money.is-danger { color: var(--red); }
.asset-line {
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}
.asset-line span:first-child {
  color: var(--muted);
  font-weight: 800;
}

/* ===== Turn / dice ===== */
.turn-card {
  padding: 1rem 0.95rem 0.95rem;
  text-align: center;
}
.turn-card .round-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.turn-card .round-line strong {
  color: var(--muted);
  font-weight: 800;
}
#turn-label {
  margin: 0.2rem 0 0;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
}

.dice-pair {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.95rem 0 1rem;
}
.die {
  --pip: #d94c4c;
  width: 54px;
  height: 54px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  padding: 8px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 28% 24%, #ffffff, transparent 42%),
    linear-gradient(160deg, #ffffff, #f2ebe3);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 5px 0 #ddd2c4,
    0 10px 18px rgba(120, 95, 70, 0.16);
  color: transparent;
  font-size: 0;
}
.die i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pip);
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.15);
  opacity: 0;
}
.die[data-face="1"] i:nth-child(5),
.die[data-face="2"] i:nth-child(1),
.die[data-face="2"] i:nth-child(9),
.die[data-face="3"] i:nth-child(1),
.die[data-face="3"] i:nth-child(5),
.die[data-face="3"] i:nth-child(9),
.die[data-face="4"] i:nth-child(1),
.die[data-face="4"] i:nth-child(3),
.die[data-face="4"] i:nth-child(7),
.die[data-face="4"] i:nth-child(9),
.die[data-face="5"] i:nth-child(1),
.die[data-face="5"] i:nth-child(3),
.die[data-face="5"] i:nth-child(5),
.die[data-face="5"] i:nth-child(7),
.die[data-face="5"] i:nth-child(9),
.die[data-face="6"] i:nth-child(1),
.die[data-face="6"] i:nth-child(3),
.die[data-face="6"] i:nth-child(4),
.die[data-face="6"] i:nth-child(6),
.die[data-face="6"] i:nth-child(7),
.die[data-face="6"] i:nth-child(9) { opacity: 1; }
.die[data-face="0"] {
  color: var(--muted);
  font: 800 1.2rem var(--display);
  display: grid;
  place-items: center;
}
.die[data-face="0"] i { display: none; }
.die.is-rolling { animation: dice-shake 90ms linear infinite alternate; }
@keyframes dice-shake {
  from { transform: rotate(-7deg) translateY(-2px); }
  to { transform: rotate(7deg) translateY(2px); }
}

.primary-action,
.secondary-action {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.04em;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}
.primary-action {
  color: #fff;
  background: var(--coral);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 6px 16px rgba(232, 116, 85, 0.32);
  text-transform: uppercase;
}
.primary-action:hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-1px);
}
.primary-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.secondary-action {
  margin-top: 0.45rem;
  color: var(--text);
  background: #fff3d4;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 4px 10px rgba(180, 140, 60, 0.16);
}

/* ===== Board legend ===== */
.legend-card {
  padding: 0.9rem 0.95rem 0.95rem;
}
.legend-card h2 {
  margin: 0 0 0.65rem;
  font: 800 0.78rem/1.2 var(--display);
  color: var(--text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.legend-list li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 700;
}
.legend-dot {
  width: 14px;
  height: 14px;
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.legend-dot.property { background: var(--coral); }
.legend-dot.question { background: var(--lavender); border-radius: 4px; color: transparent; font-size: 0; }
.legend-dot.station { background: var(--aqua); }
.legend-dot.tax { background: #b8aea0; }

/* ===== Board frame + perimeter tiles (center untouched below) ===== */
.board-section {
  min-width: 0;
  display: grid;
  place-items: center;
}
.board {
  --tile-r: 12px;
  --board-ivory: #f5f1e8;
  --board-ivory-deep: #ebe4d6;
  width: min(100%, 920px, calc(100vh - 7.25rem));
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(11, 1fr);
  gap: 4px;
  padding: 14px;
  position: relative;
  overflow: hidden;
  border: none;
  border-radius: 36px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, 0.55), transparent 58%),
    linear-gradient(165deg, #faf7f0 0%, var(--board-ivory) 45%, var(--board-ivory-deep) 100%);
  box-shadow:
    0 18px 40px rgba(120, 95, 70, 0.14),
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    inset 0 10px 28px rgba(150, 120, 90, 0.08),
    inset 0 -8px 22px rgba(160, 130, 95, 0.06);
}
.board::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 28px;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.4),
    inset 0 0 24px rgba(170, 140, 100, 0.07);
  z-index: 1;
}
.board::after {
  content: none;
}

/* Raised 3D tile cards */
.board-cell {
  --tone: #efe8de;
  --tone-deep: #e0d6c8;
  --cell-color: var(--tone);
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  border: none;
  border-radius: var(--tile-r);
  background:
    radial-gradient(circle at 30% 18%, rgba(255, 255, 255, 0.92), transparent 48%),
    linear-gradient(180deg, #fffefb 0%, color-mix(in srgb, var(--tone) 35%, #fffaf3) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 -2px 6px rgba(140, 110, 80, 0.06) inset,
    0 3px 0 color-mix(in srgb, var(--tone-deep) 80%, #c8b8a4),
    0 7px 14px rgba(120, 95, 70, 0.12);
  text-align: center;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.board-cell:hover {
  transform: translateY(-2px);
  z-index: 5;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 4px 0 color-mix(in srgb, var(--tone-deep) 75%, #c0ae98),
    0 12px 18px rgba(120, 95, 70, 0.14);
}

.board-cell.tone-coral { --tone: #f5d0c4; --tone-deep: #e8b4a4; --cell-color: var(--coral); }
.board-cell.tone-lavender { --tone: #e6d8f2; --tone-deep: #ceb8e0; --cell-color: var(--lavender); }
.board-cell.tone-aqua { --tone: #d4e8f4; --tone-deep: #b4d2e4; --cell-color: var(--aqua); }
.board-cell.tone-mint { --tone: #d8eadc; --tone-deep: #b8d4c0; --cell-color: var(--mint); }
.board-cell.tone-sand { --tone: #eadfc8; --tone-deep: #d4c4a4; --cell-color: #c4a574; }

.board-cell .color-bar {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  height: 7px;
  border-radius: var(--tile-r) var(--tile-r) 0 0;
  background: var(--cell-color);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
  z-index: 2;
}
.board-cell.question .color-bar,
.board-cell.corner .color-bar,
.board-cell.tax .color-bar {
  display: none;
}

.cell-stage {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 4px 3px 2px;
}
.cell-art-frame {
  position: relative;
  z-index: 1;
  width: 92%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}
.cell-art {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 2px 2px rgba(120, 90, 60, 0.12));
}
.cell-art.is-failed {
  display: none;
}
.cell-art-fallback {
  display: none;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: clamp(0.85rem, 1.6vw, 1.4rem);
  line-height: 1;
  filter: drop-shadow(0 2px 1px rgba(100, 70, 40, 0.16));
}
.cell-art-fallback.is-visible {
  display: grid;
}
.cell-blob { display: none; }
.cell-icon {
  position: relative;
  z-index: 1;
  font-size: clamp(0.85rem, 1.6vw, 1.4rem);
  line-height: 1;
  filter: drop-shadow(0 2px 1px rgba(100, 70, 40, 0.16));
}

.cell-foot {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 100%;
  padding: 3px 3px 5px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 55%),
    color-mix(in srgb, var(--tone) 70%, #fff8f0);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.cell-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
  padding: 0 2px;
  margin: 0;
  font-size: clamp(0.34rem, 0.56vw, 0.58rem);
  font-weight: 800;
  line-height: 1.12;
  color: var(--text);
  letter-spacing: -0.01em;
}

.cell-price {
  width: auto;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: color-mix(in srgb, var(--text) 72%, var(--cell-color));
  font-size: clamp(0.34rem, 0.52vw, 0.54rem);
  font-weight: 800;
}
.cell-price.is-fee { color: #b04840; }
.cell-price.is-bonus { color: #2f8a58; }

.board-cell.question.tone-lavender,
.board-cell.question.tone-aqua {
  background:
    radial-gradient(circle at 30% 16%, rgba(255, 255, 255, 0.9), transparent 46%),
    linear-gradient(180deg, #fffefb, color-mix(in srgb, var(--tone) 45%, #fffaf3));
}
.board-cell.question .cell-price { display: none; }
.q-mark {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(22px, 3vw, 34px);
  height: clamp(22px, 3vw, 34px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.5), transparent 50%),
    linear-gradient(145deg, color-mix(in srgb, var(--cell-color) 70%, #fff), var(--cell-color));
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
  color: #fff;
  font: 900 clamp(0.9rem, 1.8vw, 1.35rem) / 1 var(--display);
}

.board-cell.corner .cell-stage { min-height: 52%; }
.board-cell.corner .cell-art-frame { width: 96%; }
.board-cell.corner .cell-name {
  font-size: clamp(0.36rem, 0.6vw, 0.62rem);
}
.board-cell.corner .cell-icon,
.board-cell.corner .cell-art-fallback {
  font-size: clamp(1.05rem, 2.1vw, 1.75rem);
}

.board-cell.is-owned::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--owner-color);
  box-shadow: 0 0 0 2px #fff, 0 2px 4px rgba(0, 0, 0, 0.14);
  z-index: 8;
  pointer-events: none;
}

.board-cell.is-selected {
  z-index: 6;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 3px 0 color-mix(in srgb, var(--tone-deep) 80%, #c8b8a4),
    0 0 0 2px color-mix(in srgb, var(--coral) 55%, transparent),
    0 10px 18px rgba(120, 95, 70, 0.16);
}

.tokens {
  position: absolute;
  inset: auto 3px 28% auto;
  display: flex;
  z-index: 9;
  pointer-events: none;
}
.piece {
  width: clamp(16px, 1.85vw, 24px);
  height: clamp(16px, 1.85vw, 24px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid white;
  font-size: clamp(0.5rem, 0.9vw, 0.76rem);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}
.piece + .piece { margin-left: -5px; }
.piece.player {
  background: linear-gradient(145deg, #c8b0ff, #8a68e0);
}
.piece.bot {
  background: linear-gradient(145deg, #ffc0d4, #e878a0);
}
.piece.is-moving { animation: piece-pop 180ms ease; }
@keyframes piece-pop {
  50% { transform: translateY(-8px) scale(1.15); }
}

/* ===== Board center stage ===== */
.board-center {
  grid-column: 2 / 11;
  grid-row: 2 / 11;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: start;
  justify-items: center;
  padding: clamp(0.45rem, 1.2vw, 0.9rem) clamp(0.55rem, 1.5vw, 1.1rem);
  overflow: hidden;
  pointer-events: none;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.center-texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
  background:
    radial-gradient(ellipse 70% 55% at 50% 45%, rgba(255, 252, 246, 0.55), transparent 70%),
    radial-gradient(circle at 20% 25%, rgba(210, 190, 160, 0.12), transparent 26%),
    radial-gradient(circle at 78% 70%, rgba(190, 175, 150, 0.1), transparent 28%),
    repeating-linear-gradient(
      118deg,
      transparent 0 3px,
      rgba(180, 160, 130, 0.03) 3px 4px
    ),
    repeating-linear-gradient(
      26deg,
      transparent 0 5px,
      rgba(160, 140, 110, 0.025) 5px 6px
    );
}

.center-pebbles {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.pebble {
  position: absolute;
  border-radius: 50% 42% 55% 48%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.5), transparent 48%),
    linear-gradient(145deg, #d9d0c2, #b8ad9a);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 2px 4px rgba(120, 95, 70, 0.1);
  opacity: 0.38;
}
.pebble.p1 { width: 12px; height: 9px; top: 17%; left: 13%; transform: rotate(18deg); }
.pebble.p2 { width: 8px; height: 7px; top: 26%; right: 16%; transform: rotate(-22deg); opacity: 0.28; }
.pebble.p3 { width: 14px; height: 10px; bottom: 24%; left: 20%; transform: rotate(8deg); opacity: 0.32; }
.pebble.p4 { width: 7px; height: 6px; bottom: 34%; right: 24%; transform: rotate(40deg); opacity: 0.26; }
.pebble.p5 { width: 10px; height: 8px; top: 58%; left: 46%; transform: rotate(-12deg); opacity: 0.28; }

.center-message {
  position: relative;
  z-index: 3;
  max-width: min(92%, 360px);
  margin: 0.2rem auto 0;
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  background:
    radial-gradient(circle at 28% 28%, rgba(255, 255, 255, 0.98), transparent 55%),
    linear-gradient(180deg, #fffefb, #f5ece2);
  color: #5a5046;
  font-size: clamp(0.54rem, 0.95vw, 0.7rem);
  font-weight: 750;
  letter-spacing: 0.01em;
  text-align: center;
  line-height: 1.35;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 2px 0 #e2d6c6,
    0 8px 16px rgba(140, 110, 80, 0.12);
}

.center-brand {
  position: relative;
  z-index: 2;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
  max-width: min(86%, 440px);
  margin-top: clamp(0.4rem, 2vw, 1.1rem);
  transform: perspective(560px) rotateX(5deg);
}

.center-eyebrow {
  margin: 0;
  font-size: clamp(0.5rem, 0.9vw, 0.66rem);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #5e544a;
}

.tycoon-title {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12em;
  line-height: 1;
  font-size: clamp(1.55rem, 3.6vw, 2.85rem);
  font-weight: 900;
  letter-spacing: 0.01em;
}
.tycoon-title .title-word {
  display: flex;
  justify-content: center;
  gap: 0.06em;
}
.tycoon-title .title-word > span {
  display: inline-grid;
  place-items: center;
  min-width: 0.88em;
  padding: 0.05em 0.03em 0.1em;
  border-radius: 0.22em;
  color: #fffef9;
  transform: translateY(0);
  animation: letter-bob 2.8s ease-in-out infinite;
  animation-delay: var(--d, 0s);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}
.tycoon-title .property > span {
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.48), transparent 48%),
    linear-gradient(165deg, #f29a7c 0%, #e87455 48%, #c45a3e 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45) inset,
    0 3px 0 #b04e36,
    0 6px 10px rgba(120, 50, 30, 0.2);
}
.tycoon-title .tycoon > span {
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.48), transparent 48%),
    linear-gradient(165deg, #8fd4b0 0%, #6fbf9a 48%, #4fa07c 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45) inset,
    0 3px 0 #3f8a68,
    0 6px 10px rgba(40, 90, 70, 0.18);
}
@keyframes letter-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.board-hint {
  margin: 0.2rem 0 0;
  max-width: 300px;
  color: #5a5046;
  font-size: clamp(0.55rem, 1vw, 0.74rem);
  font-weight: 700;
  line-height: 1.4;
}

.clay-deck {
  position: absolute;
  z-index: 2;
  width: clamp(92px, 13vw, 132px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
  filter: drop-shadow(0 10px 16px rgba(100, 70, 40, 0.18));
}
.clay-deck.data {
  top: 12%;
  left: 3%;
  transform: rotate(-12deg);
}
.clay-deck.quiz {
  bottom: 8%;
  right: 2%;
  transform: rotate(10deg);
}
.clay-deck .deck-art {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.clay-deck span {
  max-width: 96%;
  padding: 0.28rem 0.45rem;
  border-radius: 999px;
  color: #fff;
  font-size: clamp(0.4rem, 0.72vw, 0.54rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.3) inset,
    0 3px 8px rgba(60, 40, 20, 0.14);
}
.clay-deck.data span {
  background: linear-gradient(160deg, #6eb8e0, #3f92c4);
}
.clay-deck.quiz span {
  background: linear-gradient(160deg, #f09868, #e07040);
}

.reward-rule {
  position: absolute;
  z-index: 2;
  left: 4%;
  bottom: 9%;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: clamp(104px, 15vw, 136px);
  padding: 0.5rem 0.7rem;
  border-radius: 14px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.98), transparent 55%),
    linear-gradient(180deg, #fffefb, #f5ebe1);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 3px 0 #e0d4c4,
    0 10px 18px rgba(140, 110, 80, 0.14);
  text-align: center;
}
.reward-rule > div {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  padding: 0.32rem 0.15rem;
}
.reward-rule > div + div {
  border-top: 1px solid rgba(200, 185, 165, 0.55);
}
.reward-rule span {
  font-size: clamp(0.5rem, 0.9vw, 0.64rem);
  font-weight: 750;
  line-height: 1.2;
}
.reward-rule strong {
  font-size: clamp(0.68rem, 1.15vw, 0.88rem);
  font-weight: 850;
  line-height: 1.15;
}
.reward-rule .ok span,
.reward-rule .ok strong { color: #2f8a58; }
.reward-rule .bad span,
.reward-rule .bad strong { color: #c45a42; }

@media (max-width: 900px) {
  .clay-deck { width: clamp(72px, 18vw, 100px); }
  .clay-deck.data { top: 10%; left: 1%; }
  .clay-deck.quiz { bottom: 6%; right: 0; }
  .reward-rule { left: 2%; bottom: 6%; }
}

/* ===== Right panel ===== */
.log-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0.7rem;
  min-width: 0;
  width: 100%;
  align-self: stretch;
  min-height: min(100%, 860px);
}

.goal-card,
.property-summary,
.game-log {
  background: #fffefb;
  border: none;
  border-radius: 20px;
  box-shadow:
    0 8px 18px rgba(120, 95, 70, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.95) inset;
}

.goal-card {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.85rem 0.9rem;
}
.goal-trophy {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.85), transparent 50%),
    linear-gradient(145deg, #f0e0c4, #d8c4a0);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 3px 0 #cbb894,
    0 6px 12px rgba(140, 110, 70, 0.12);
  font-size: 1.35rem;
  line-height: 1;
}
.goal-copy {
  min-width: 0;
}
.goal-card strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.2;
}
.goal-card small {
  display: block;
  margin-top: 0.28rem;
  color: #6a5f54;
  font-size: 0.66rem;
  line-height: 1.4;
  font-weight: 650;
}

.property-summary,
.game-log {
  padding: 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.property-summary h2,
.game-log h2 {
  margin: 0 0 0.65rem;
  font: 800 0.76rem/1.2 var(--display);
  color: var(--text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.owned-list {
  display: grid;
  gap: 0.4rem;
  max-height: 168px;
  overflow: auto;
  padding-right: 0.15rem;
}
.owned-empty {
  margin: 0.15rem 0 0;
  color: #8c8175;
  font-size: 0.72rem;
  font-weight: 650;
  text-align: center;
  padding: 0.55rem 0.4rem;
}
.owned-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.45rem 0.55rem;
  border-radius: 12px;
  background: #f5efe6;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}
.owned-color {
  width: 6px;
  height: 22px;
  border-radius: 999px;
  justify-self: center;
}
.owned-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.7rem;
  font-weight: 750;
  color: var(--text);
}
.owned-rent {
  font-size: 0.7rem;
  font-weight: 850;
  color: #4a4038;
  letter-spacing: 0.01em;
}

.game-log {
  min-height: 240px;
}
.game-log ol,
#game-log {
  margin: 0;
  padding: 0 0.35rem 0 1.25rem;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #b8aea0 transparent;
}
#game-log::-webkit-scrollbar {
  width: 6px;
}
#game-log::-webkit-scrollbar-thumb {
  background: #b8aea0;
  border-radius: 999px;
}
#game-log li {
  margin-bottom: 0.42rem;
  padding-right: 0.2rem;
  color: #6a5f54;
  font-size: 0.68rem;
  line-height: 1.45;
  font-weight: 650;
}
#game-log li:last-child {
  color: var(--text);
  font-weight: 800;
}

.restart-button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  color: var(--coral);
  background: #fffefb;
  font-weight: 850;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 6px 16px rgba(120, 95, 70, 0.1);
  transition: transform 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
}
.restart-button:hover {
  color: #d45f45;
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 8px 18px rgba(120, 95, 70, 0.14);
}
.restart-button:active {
  transform: translateY(0);
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(70, 50, 40, 0.45);
  backdrop-filter: blur(8px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(620px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 1.2rem;
  border-radius: 26px;
  border: none;
  background: var(--cream-2);
  box-shadow: 0 24px 60px rgba(80, 50, 30, 0.28), var(--shadow-inset);
  animation: modal-in 180ms ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
}

.question-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
}
.question-symbol {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: white;
  background: linear-gradient(145deg, #d4b8ff, #9f7ae8);
  font: 800 2rem var(--display);
  box-shadow: 0 6px 0 #7a58c0;
}
.question-top p {
  margin: 0;
  color: #8a6ad0;
  font-size: 0.74rem;
  font-weight: 800;
}
.question-top h2 {
  margin: 0.05rem 0 0;
  font: 800 1.4rem var(--display);
}
.question-stakes {
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-pill);
  background: var(--gold-soft);
  color: #8a6a20;
  font-size: 0.7rem;
  font-weight: 800;
}
.question-stem {
  margin: 1rem 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.65;
}
.answer-list { display: grid; gap: 0.5rem; }
.answer-option {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 0.65rem;
  align-items: center;
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 16px;
  background: #f5efe6;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font-weight: 700;
  box-shadow: var(--shadow-inset);
  transition: transform 0.1s ease, background 0.1s ease;
}
.answer-option:hover:not(:disabled) {
  background: var(--sky-soft);
  transform: translateY(-1px);
}
.answer-option:focus-visible {
  outline: 3px solid rgba(126, 200, 240, 0.45);
  outline-offset: 2px;
}
.answer-letter {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(160, 120, 80, 0.12);
  font-weight: 800;
}
.answer-option.is-correct { background: var(--mint-soft); }
.answer-option.is-wrong { background: #ffe0dc; }
.answer-feedback {
  margin-top: 0.85rem;
  padding: 0.75rem;
  border-radius: 16px;
  background: #f5efe6;
  font-size: 0.8rem;
  line-height: 1.55;
  font-weight: 600;
}
.answer-feedback strong { display: block; margin-bottom: 0.15rem; font-weight: 800; }
.answer-feedback.correct strong { color: var(--green); }
.answer-feedback.wrong strong { color: var(--red); }
.modal-continue { margin-top: 0.85rem; }

.rules-card,
.gameover-card { position: relative; }
.rules-card h2,
.gameover-card h2,
.lobby-card h2 {
  font: 800 1.5rem var(--display);
}
.rules-card li {
  margin: 0.55rem 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.84rem;
  font-weight: 600;
}
.modal-close {
  position: absolute;
  right: 0.85rem;
  top: 0.7rem;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--sand);
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.gameover-card {
  text-align: center;
  width: min(420px, 94vw);
}
.gameover-icon { font-size: 3.5rem; }
.gameover-card p {
  color: var(--muted);
  line-height: 1.55;
  font-weight: 600;
}
.secondary-link {
  display: inline-block;
  margin-top: 0.85rem;
  color: var(--peach);
  text-decoration: none;
  font-weight: 800;
}

.lobby-card { width: min(480px, 94vw); }
.lobby-card h2 {
  margin: 0;
  text-align: center;
}
.lobby-intro {
  margin: 0.45rem auto 0.9rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.5;
  font-weight: 600;
}
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.mode-tab {
  min-height: 48px;
  border: none;
  border-radius: 16px;
  background: #f5efe6;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  box-shadow: var(--shadow-inset);
}
.mode-tab.is-active {
  background: linear-gradient(160deg, #ffb07a, #ff8a4a);
  color: white;
  box-shadow: 0 5px 0 #e07040;
}
.join-fields {
  display: grid;
  gap: 0.65rem;
  margin: 0.9rem 0;
}
.join-fields label { display: grid; gap: 0.3rem; }
.join-fields label span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}
.join-fields input {
  width: 100%;
  min-height: 46px;
  border: none;
  border-radius: 14px;
  padding: 0.55rem 0.8rem;
  color: var(--ink);
  background: #f5efe6;
  outline: none;
  font-weight: 700;
  box-shadow: var(--shadow-inset);
}
.join-fields input:focus {
  box-shadow: 0 0 0 3px rgba(255, 155, 107, 0.3), var(--shadow-inset);
}
.join-error {
  margin: -0.35rem 0 0.65rem;
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 700;
}
.local-note {
  margin: 0.65rem 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.66rem;
  font-weight: 600;
}

/* ===== Responsive ===== */
@media (max-width: 1508px) {
  .tycoon-shell {
    width: min(100% - 1.25rem, 1508px);
  }
  .game-layout {
    grid-template-columns: minmax(190px, 230px) minmax(0, 1fr) minmax(210px, 250px);
  }
}

@media (max-width: 1440px) {
  .board {
    width: min(100%, 820px, calc(100vh - 6.75rem));
  }
  .log-panel {
    min-height: min(100%, calc(100vh - 6.75rem));
  }
}

@media (max-width: 1100px) {
  .game-layout {
    grid-template-columns: minmax(170px, 210px) minmax(0, 1fr);
  }
  .log-panel {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1.4fr);
    grid-template-rows: auto;
    min-height: 0;
    align-items: stretch;
  }
  .game-log { min-height: 220px; }
  .restart-button { grid-column: 1 / -1; }
  .board {
    width: min(100%, 720px, calc(100vh - 6.5rem));
  }
}

@media (max-width: 820px) {
  .tycoon-shell {
    width: min(100% - 1rem, 1540px);
    padding-top: 0.65rem;
  }
  .game-header {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 0.5rem;
    border-radius: 20px;
    top: 0.5rem;
  }
  .game-title { justify-self: start; }
  .header-actions { justify-self: start; flex-wrap: wrap; }
  .game-layout {
    grid-template-columns: 1fr;
  }
  .status-panel {
    grid-template-columns: 1fr 1fr;
  }
  .turn-card,
  .legend-card { grid-column: 1 / -1; }
  .log-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(220px, 1fr) auto;
  }
  .board {
    width: min(100%, 96vw, calc(100vh - 5.5rem));
  }
  .question-top { grid-template-columns: auto 1fr; }
  .question-stakes { grid-column: 1 / -1; justify-self: start; }
  .primary-action,
  .secondary-action,
  .restart-button {
    position: relative;
    z-index: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tycoon-title .title-word > span,
  .die.is-rolling,
  .piece.is-moving,
  .modal-card { animation: none !important; }
}
