:root {
  --page-bg: #efe6d3;
  --panel: #fff9ec;
  --panel-soft: #f7ecd6;
  --border: #d8c49b;
  --text: #2f281c;
  --muted: #665b48;
  --green: #23543a;
  --green-dark: #153924;
  --gold: #b8872f;
  --blue: #245b7a;
  --red: #a23a2d;
  --shadow: 0 18px 42px rgba(31, 35, 24, 0.14);
  --tile-w: 62px;
  --tile-h: 76px;
  --tile-gap: 6px;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.62), transparent 26%),
    linear-gradient(180deg, #f5ead4 0%, var(--page-bg) 58%, #dfcfaa 100%);
  line-height: 1.65;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.page-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 max(48px, env(safe-area-inset-bottom));
}

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

.breadcrumb a {
  text-decoration: none;
  border-bottom: 1px solid rgba(102, 91, 72, 0.28);
}

.hero,
.panel,
.game-shell,
.faq-panel,
.related-panel {
  background: rgba(255, 249, 236, 0.92);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 22px 24px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.15rem);
  margin-bottom: 10px;
}

h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.8rem);
  margin-bottom: 10px;
}

h3 {
  font-size: 1.12rem;
  margin-bottom: 8px;
}

p {
  margin: 0 0 1rem;
}

.lead {
  max-width: 74ch;
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-actions,
.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.button,
.game-button {
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid #cbb78c;
  padding: 12px 18px;
  background: #eadab7;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button.primary,
.game-button.primary {
  border-color: transparent;
  background: linear-gradient(180deg, #d7ac52, var(--gold));
  color: #fff9ef;
  box-shadow: 0 9px 18px rgba(184, 135, 47, 0.24);
}

.game-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.game-shell {
  padding: 14px;
  margin-bottom: 20px;
}

.status-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.status-item {
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid #e3d4af;
  border-radius: 16px;
  padding: 10px 12px;
}

.status-label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-item strong {
  display: block;
  margin-top: 4px;
  font-size: 1.12rem;
  min-height: 1.35em;
}

.game-note {
  margin: 0 0 12px;
  color: var(--muted);
}

.board-viewport {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.10), transparent 30%),
    linear-gradient(180deg, #2b7047, var(--green) 38%, var(--green-dark));
  border: 1px solid rgba(21, 57, 36, 0.45);
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
}

.mahjong-board {
  position: relative;
  width: calc(10 * (var(--tile-w) + var(--tile-gap)) + 20px);
  height: calc(8 * (var(--tile-h) + 8px) + 86px);
  min-width: calc(10 * (var(--tile-w) + var(--tile-gap)) + 20px);
  margin: 0 auto;
}

.tile {
  position: absolute;
  width: var(--tile-w);
  height: var(--tile-h);
  border: 1px solid rgba(73, 58, 34, 0.28);
  border-radius: 14px;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.9), rgba(255,255,255,0.38) 38%, transparent 39%),
    linear-gradient(180deg, #fffef8, #efe3c7);
  color: var(--green-dark);
  box-shadow:
    0 7px 0 rgba(176, 157, 116, 0.92),
    0 11px 18px rgba(12, 24, 14, 0.22);
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: 6px 4px;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
  touch-action: manipulation;
}

.tile-symbol {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
}

.tile-name {
  font: 700 0.64rem/1.1 system-ui, sans-serif;
  letter-spacing: 0.03em;
  text-align: center;
}

.tile.kind-bamboo .tile-symbol,
.tile.kind-season .tile-symbol {
  color: var(--green);
}

.tile.kind-circle .tile-symbol,
.tile.kind-dragon .tile-symbol {
  color: var(--red);
}

.tile.kind-character .tile-symbol,
.tile.kind-wind .tile-symbol,
.tile.kind-flower .tile-symbol {
  color: var(--blue);
}

.tile.blocked {
  opacity: 0.48;
  filter: saturate(0.55);
  cursor: default;
}

.tile.free:hover,
.tile.free:focus-visible {
  transform: translateY(-3px);
  outline: 3px solid rgba(255, 230, 164, 0.82);
  outline-offset: 2px;
}

.tile.selected {
  transform: translateY(-5px) scale(1.04);
  outline: 4px solid #ffe5a0;
  outline-offset: 2px;
  box-shadow:
    0 7px 0 rgba(176, 157, 116, 0.92),
    0 0 0 6px rgba(255, 229, 160, 0.26),
    0 16px 28px rgba(12, 24, 14, 0.30);
}

.tile.hint {
  animation: hintPulse 0.7s ease-in-out 3;
}

.tile.shake {
  animation: shake 0.26s ease-in-out;
}

.tile.removing {
  transform: scale(0.2);
  opacity: 0;
}

@keyframes hintPulse {
  50% {
    transform: translateY(-5px) scale(1.08);
    outline: 4px solid #ffe5a0;
  }
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 34, 24, 0.56);
  z-index: 20;
}

.overlay[hidden] {
  display: none;
}

.overlay-panel {
  width: min(520px, 100%);
  padding: 28px;
  border-radius: 24px;
  background: rgba(255, 249, 236, 0.97);
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: 0 22px 46px rgba(9, 20, 12, 0.30);
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.panel,
.faq-panel,
.related-panel {
  padding: 22px 24px;
}

.panel ul,
.panel ol {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
}

.panel li {
  margin-bottom: 0.45rem;
}

.faq-panel,
.related-panel {
  margin-top: 18px;
}

.faq-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.faq-list details {
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid #e1d0aa;
  border-radius: 16px;
  padding: 14px 16px;
}

.faq-list summary {
  cursor: pointer;
  font-weight: 700;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.related-card {
  display: block;
  min-height: 100%;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid #e1d0aa;
  text-decoration: none;
}

.related-card strong {
  display: block;
  margin-bottom: 5px;
}

.related-card span {
  color: var(--muted);
}

@media (max-width: 760px) {
  :root {
    --tile-w: 54px;
    --tile-h: 68px;
    --tile-gap: 5px;
  }

  .page-shell {
    width: min(100%, calc(100vw - 16px));
    padding-top: 10px;
  }

  .hero,
  .panel,
  .game-shell,
  .faq-panel,
  .related-panel {
    border-radius: 18px;
  }

  .hero,
  .panel,
  .faq-panel,
  .related-panel {
    padding: 16px;
  }

  .hero {
    padding: 12px 14px;
    margin-bottom: 10px;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 0.72rem;
  }

  h1 {
    font-size: 1.7rem;
    margin-bottom: 6px;
  }

  .lead {
    font-size: 0.96rem;
    line-height: 1.38;
    margin-bottom: 0;
  }

  .hero-actions {
    margin-top: 8px;
  }

  .hero-actions .button {
    min-height: 44px;
    padding: 9px 12px;
  }

  .game-shell {
    padding: 10px;
    margin-bottom: 16px;
  }

  .status-bar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 8px;
  }

  .status-item {
    padding: 7px 6px;
    border-radius: 12px;
  }

  .status-label {
    font-size: 0.62rem;
  }

  .status-item strong {
    font-size: 0.9rem;
    min-height: 1.2em;
  }

  .game-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
  }

  .game-button {
    width: 100%;
    min-height: 44px;
    padding: 8px 8px;
    font-size: 0.92rem;
  }

  .game-note {
    margin-bottom: 8px;
    font-size: 0.9rem;
    line-height: 1.35;
  }

  .board-viewport {
    padding: 8px;
  }

  .tile-symbol {
    font-size: 1.32rem;
  }

  .tile-name {
    font-size: 0.58rem;
  }

  .content-grid,
  .faq-list,
  .related-grid {
    grid-template-columns: 1fr;
  }
}
