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

:root {
  --bg: #11100d;
  --surface: #1c1a15;
  --surface-2: #29251d;
  --surface-3: #342f24;
  --border: #554d3d;
  --text: #fff8e8;
  --text-muted: #c2b59c;
  --sand: #e8c36a;
  --moss: #82a862;
  --sky: #87b7c9;
  --clay: #b86b4b;
  --shadow: rgba(0, 0, 0, 0.35);
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(135, 183, 201, 0.18), transparent 34rem),
    linear-gradient(135deg, #11100d 0%, #1b1710 54%, #0f120d 100%);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.back-bar {
  position: relative;
  z-index: 10;
  padding: 0.75rem 1.5rem;
  background: rgba(17, 16, 13, 0.82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.16s ease;
}

.back-link:hover {
  color: var(--text);
}

.rocks-shell {
  width: min(1180px, calc(100% - 2rem));
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  padding: 1rem 0 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
  align-items: stretch;
}

.game-panel,
.side-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(28, 26, 21, 0.82);
  box-shadow: 0 22px 70px var(--shadow);
  backdrop-filter: blur(18px);
}

.game-panel {
  min-height: 720px;
  padding: clamp(0.85rem, 2vw, 1.25rem);
  display: grid;
  grid-template-rows: auto auto minmax(420px, 1fr) auto;
  gap: 0.85rem;
}

.top-strip,
.stats-row,
.control-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-strip {
  justify-content: space-between;
}

.eyebrow,
.panel-label {
  color: var(--sand);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2.1rem, 6vw, 4.6rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.icon-button,
.control-button,
.drop-button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.075);
  cursor: pointer;
  font-weight: 850;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.icon-button {
  width: 44px;
  font-size: 1.35rem;
}

.icon-button:hover,
.control-button:hover,
.drop-button:hover {
  border-color: rgba(232, 195, 106, 0.62);
  background: rgba(232, 195, 106, 0.12);
  transform: translateY(-1px);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-box {
  min-height: 76px;
  padding: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.stat-box span {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.stat-box strong {
  display: block;
  color: var(--sand);
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.canvas-wrap {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(135, 183, 201, 0.78) 0%, rgba(189, 177, 134, 0.44) 58%, rgba(57, 45, 31, 0.78) 100%);
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  cursor: crosshair;
}

.message-card {
  position: absolute;
  left: 50%;
  top: 1rem;
  width: min(360px, calc(100% - 2rem));
  padding: 0.8rem 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(17, 16, 13, 0.76);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.message-card strong,
.message-card span {
  display: block;
}

.message-card strong {
  color: var(--text);
  font-size: 0.92rem;
}

.message-card span {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: 0.18rem;
}

.control-bar {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
}

.control-button,
.drop-button {
  width: 100%;
  padding: 0 0.8rem;
  white-space: nowrap;
}

.drop-button {
  background: linear-gradient(135deg, var(--sand), #d98946);
  border-color: rgba(255, 255, 255, 0.18);
  color: #22170c;
  min-height: 48px;
}

.drop-button:hover {
  background: linear-gradient(135deg, #f1d184, #de9558);
}

.drop-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.side-panel {
  min-height: 0;
  padding: 1rem;
  display: grid;
  align-content: start;
  gap: 0.85rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 72px);
}

.next-card,
.rules-card,
.status-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.next-card {
  padding: 0.85rem;
}

#preview-canvas {
  display: block;
  width: 100%;
  height: 150px;
  margin-top: 0.55rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
}

.rules-card,
.status-card {
  padding: 0.85rem;
}

.rules-card ul {
  list-style: none;
  display: grid;
  gap: 0.52rem;
  margin-top: 0.65rem;
}

.rules-card li,
.status-card p {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.rules-card li {
  position: relative;
  padding-left: 1rem;
}

.rules-card li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.36rem;
  height: 0.36rem;
  border-radius: 50%;
  background: var(--moss);
}

.status-card p {
  margin-top: 0.55rem;
}

@media (max-width: 900px) {
  .rocks-shell {
    grid-template-columns: 1fr;
  }

  .game-panel {
    min-height: 680px;
  }

  .side-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 620px) {
  .back-bar {
    padding: 0.65rem 1rem;
  }

  .rocks-shell {
    width: min(100% - 1rem, 1180px);
    padding: 0.5rem 0 1rem;
  }

  .game-panel {
    min-height: calc(100vh - 72px);
    grid-template-rows: auto auto minmax(360px, 1fr) auto;
  }

  .stats-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .stat-box {
    min-height: 58px;
    padding: 0.62rem 0.75rem;
  }

  .control-bar {
    grid-template-columns: 1fr;
  }

  .control-button,
  .drop-button {
    min-height: 44px;
  }
}
