:root {
  --felt: #0f3f32;
  --felt-dark: #08251f;
  --paper: #f9f7ee;
  --ink: #17231f;
  --muted: #66756f;
  --line: rgba(23, 35, 31, 0.16);
  --gold: #d99a20;
  --green: #167d55;
  --red: #b8272f;
  --blue: #1f5f8b;
  --shadow: 0 18px 45px rgba(4, 18, 15, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 12px),
    linear-gradient(135deg, var(--felt-dark), var(--felt) 48%, #174b34);
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.game-surface {
  background: rgba(249, 247, 238, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 6vw, 52px);
  line-height: 1;
}

h2 {
  font-size: clamp(28px, 5vw, 46px);
}

.icon-button {
  width: 48px;
  height: 48px;
  color: white;
  background: var(--blue);
  font-size: 26px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(31, 95, 139, 0.24);
}

.hero-row {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 14px;
  padding: 14px 22px;
  background: #edf3ef;
  border-bottom: 1px solid var(--line);
}

.hero-row div:first-child,
.timer-block {
  display: grid;
  align-content: center;
  gap: 4px;
}

#round-label,
.timer-block span,
.stat-card span,
.hint-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

#status-text {
  font-size: 17px;
}

.timer-block {
  min-width: 124px;
  padding: 10px 12px;
  text-align: right;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.timer-block strong {
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.table-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  padding: 20px 22px 24px;
}

.board-panel,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.board-panel {
  padding: 18px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 14px;
}

.card-button {
  position: relative;
  min-height: 154px;
  padding: 14px;
  color: #111;
  background:
    linear-gradient(180deg, #fffdf8, #f4f0e4);
  border: 1px solid #ded6c4;
  border-radius: 8px;
  box-shadow: 0 10px 18px rgba(30, 24, 18, 0.12);
}

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

.card-button.used {
  color: #858585;
  background: #e7e4da;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.05);
  transform: translateY(2px);
}

.card-corner {
  position: absolute;
  left: 12px;
  top: 10px;
  display: grid;
  justify-items: center;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.card-center {
  display: grid;
  min-height: 122px;
  place-items: center;
  font-size: clamp(42px, 8vw, 76px);
  font-weight: 900;
}

.card-suit-large {
  position: absolute;
  right: 12px;
  bottom: 10px;
  font-size: 34px;
  opacity: 0.78;
}

.expression-panel {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f6ef;
}

.expression-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.expression {
  min-height: 42px;
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
  font-size: 25px;
  font-weight: 800;
}

.preview {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.preview.correct {
  color: var(--green);
}

.preview.error {
  color: var(--red);
}

.operator-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.operator-grid button {
  min-height: 48px;
  color: white;
  background: #223832;
  font-size: 24px;
  font-weight: 900;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.success-button,
.ghost-button {
  min-height: 46px;
  padding: 0 14px;
  font-weight: 850;
}

.primary-button {
  color: white;
  background: var(--blue);
}

.secondary-button {
  width: 100%;
  color: var(--ink);
  background: #e9ece8;
}

.success-button {
  color: white;
  background: var(--green);
  box-shadow: 0 8px 18px rgba(22, 125, 85, 0.24);
}

.ghost-button {
  color: var(--ink);
  background: #f0eee4;
  border: 1px solid var(--line);
}

.ghost-button.light {
  color: white;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.stat-card,
.hint-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 12px;
  background: #f7f6ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-card strong {
  font-size: 30px;
}

.hint-card {
  display: grid;
  justify-content: stretch;
}

.hint-card code {
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--blue);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 14px;
  font-weight: 800;
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  color: white;
  background: rgba(5, 19, 16, 0.76);
}

.celebration[hidden] {
  display: none;
}

.celebration-panel {
  width: min(540px, 100%);
  padding: 30px;
  text-align: center;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.07) 0 2px, transparent 2px 18px),
    #113c31;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.celebration-panel p {
  margin: 12px 0 0;
  font-size: 18px;
}

.celebration-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 18px, 660px);
    padding: 10px 0;
  }

  .top-bar,
  .hero-row,
  .table-layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .hero-row,
  .table-layout {
    grid-template-columns: 1fr;
  }

  .hero-row {
    display: grid;
  }

  .timer-block {
    text-align: left;
  }

  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-button {
    min-height: 130px;
  }

  .card-center {
    min-height: 100px;
  }

  .operator-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .action-row,
  .celebration-actions {
    grid-template-columns: 1fr;
  }
}
