* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --ink: #1e293b;
  --muted: #64748b;
  --line: rgba(30, 41, 59, 0.12);
  --paper: rgba(255, 255, 255, 0.86);
  --accent: #0f9f86;
  --accent-dark: #06725f;
  --warm: #ffb000;
  --rose: #f04e78;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 176, 0, 0.32), transparent 28rem),
    radial-gradient(circle at 82% 20%, rgba(15, 159, 134, 0.28), transparent 26rem),
    linear-gradient(135deg, #fff8e8 0%, #e9fff8 46%, #fff1f5 100%);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar,
.hero,
.status-grid,
.board-wrap,
.actions,
.next-links {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-links a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(15, 159, 134, 0.2);
  border-radius: 8px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.ghost-button,
.secondary-button,
.primary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.ghost-button {
  padding: 9px 12px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 159, 134, 0.2);
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-top: 8px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--rose);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(42px, 14vw, 78px);
  line-height: 0.92;
  letter-spacing: 0;
}

.score-card,
.status-item,
.board-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(14px);
}

.score-card {
  min-width: 88px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}

.score-card span,
.status-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.score-card strong {
  display: block;
  font-size: 32px;
  line-height: 1;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.status-item {
  min-width: 0;
  padding: 12px 8px;
  border-radius: 8px;
  text-align: center;
}

.status-item strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  line-height: 1;
}

.board-wrap {
  position: relative;
  padding: 14px;
  border-radius: 8px;
}

.combo-banner {
  min-height: 28px;
  margin-bottom: 12px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.tile {
  aspect-ratio: 1;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-size: clamp(28px, 10vw, 48px);
  font-weight: 950;
  line-height: 1;
  background: linear-gradient(160deg, #0f9f86, #08705e);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.16), 0 10px 20px rgba(15, 159, 134, 0.22);
  transform: translateZ(0);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 180ms ease;
  cursor: pointer;
}

.tile:nth-child(3n + 2) {
  background: linear-gradient(160deg, #ffb000, #e77700);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.14), 0 10px 20px rgba(231, 119, 0, 0.22);
}

.tile:nth-child(3n) {
  background: linear-gradient(160deg, #f04e78, #b92c56);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.15), 0 10px 20px rgba(240, 78, 120, 0.2);
}

.tile.is-selected {
  transform: translateY(-5px) scale(1.04);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18), 0 16px 28px rgba(15, 23, 42, 0.22);
}

.tile.is-clearing {
  opacity: 0;
  transform: scale(0.54) rotate(8deg);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 12px 24px rgba(15, 159, 134, 0.26);
}

.secondary-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.next-links {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: auto 0 0;
}

.next-card {
  display: grid;
  gap: 3px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-decoration: none;
}

.next-card-primary {
  border-color: rgba(15, 159, 134, 0.26);
  background: linear-gradient(135deg, rgba(15, 159, 134, 0.12), rgba(255, 176, 0, 0.16));
}

.next-card span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.next-card strong {
  font-size: 16px;
  line-height: 1.35;
}

.next-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 5;
  max-width: min(92vw, 440px);
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: rgba(15, 23, 42, 0.9);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 380px) {
  .game-shell {
    padding: 12px;
    gap: 12px;
  }

  .board {
    gap: 8px;
  }

  .status-item strong {
    font-size: 24px;
  }
}
