:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101014;
  color: #fff7e8;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 5%, rgba(255, 190, 97, 0.24), transparent 26rem),
    radial-gradient(circle at 80% 12%, rgba(95, 160, 255, 0.2), transparent 28rem),
    linear-gradient(135deg, #151117 0%, #23202c 45%, #111827 100%);
}

button {
  font: inherit;
}

.game-shell {
  width: min(1240px, calc(100% - 1.5rem));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1rem;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem 2rem;
  align-items: end;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid rgba(255, 247, 232, 0.16);
  border-radius: 1.5rem;
  background: rgba(13, 13, 18, 0.62);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: #ffc56c;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: -0.06em;
}

.intro p:last-of-type {
  max-width: 58rem;
  margin: 0.75rem 0 0;
  color: #d7c8af;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.45;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: flex-end;
}

.save-button,
.trash-button,
.tab-button {
  min-height: 2.7rem;
  border: 2px solid #241507;
  border-radius: 999px;
  padding: 0 1.2rem;
  background: #ffc56c;
  color: #241507;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 2px 2px 0 #241507, 0 12px 30px rgba(255, 166, 48, 0.18);
}

.tabs {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.tab-button {
  min-height: 2.4rem;
  background: #fff7e8;
}

.tab-button.selected {
  background: #ffc56c;
}

.tab-panel {
  display: none;
}

.tab-panel.selected {
  display: block;
}

.trash-button {
  background: #ff8a7a;
}

.trash-button[aria-pressed="true"] {
  background: #ff4d38;
  color: #fff7e8;
}

.save-button:disabled {
  background: #d8d0c1;
  color: #6d6558;
  cursor: not-allowed;
  opacity: 0.82;
}

#status {
  color: #c8d7ff;
  font-size: 0.9rem;
  text-align: right;
}

#status[data-state="ok"] {
  color: #b6f0a8;
}

#status[data-state="error"] {
  color: #ffb0a6;
}

.board-card {
  position: relative;
  min-height: 520px;
  border: 1px solid rgba(255, 247, 232, 0.16);
  border-radius: 1.5rem;
  overflow: hidden;
  background: #86b8e7;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.42);
}

.saved-panel {
  min-height: 520px;
  border: 1px solid rgba(255, 247, 232, 0.16);
  border-radius: 1.5rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  background: rgba(13, 13, 18, 0.72);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.42);
}

.saved-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.saved-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: -0.04em;
}

.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  color: #d7c8af;
}

.saved-card {
  border: 2px solid #241507;
  border-radius: 1rem;
  overflow: hidden;
  background: #fff7e8;
  color: #241507;
  box-shadow: 4px 4px 0 #241507;
}

.saved-card canvas {
  display: block;
  width: 100%;
  height: 140px;
  background: linear-gradient(#93c5fd 0 68%, #6f8f42 68% 100%);
}

.saved-card-body {
  padding: 0.8rem;
}

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

.saved-card span {
  margin-top: 0.25rem;
  color: #6b5a46;
  font-size: 0.9rem;
}

#game {
  display: block;
  width: 100%;
  height: min(68vh, 660px);
  min-height: 520px;
  touch-action: none;
}

.tray {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: -76px;
  display: grid;
  gap: 0.7rem;
  width: 128px;
  padding: 1rem 0.65rem 1rem 1rem;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 247, 232, 0.22);
  border-left: 0;
  border-radius: 0 1.2rem 1.2rem 0;
  background: rgba(24, 20, 18, 0.88);
  box-shadow: 18px 18px 50px rgba(0, 0, 0, 0.28);
  transition: left 160ms ease;
}

.tray:hover,
.tray:focus-within {
  left: 0;
}

.tray-label {
  writing-mode: vertical-rl;
  position: absolute;
  top: 1rem;
  right: 0.34rem;
  color: #ffd99a;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.shape-pick {
  width: 70px;
  height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 0.45rem;
  cursor: grab;
  box-shadow: inset 0 -8px rgba(0, 0, 0, 0.16), 0 8px 18px rgba(0, 0, 0, 0.2);
}

.shape-pick:active {
  cursor: grabbing;
}

.shape-pick.block {
  background: #b7503c;
}

.shape-pick.column {
  width: 44px;
  height: 84px;
  margin-left: 13px;
  background: #d48b4c;
}

.shape-pick.square {
  width: 58px;
  height: 58px;
  margin-left: 6px;
  background: #8f6f55;
}

.shape-pick.roof {
  border-radius: 0.9rem 0.9rem 0.35rem 0.35rem;
  background: #703c79;
}

@media (max-width: 760px) {
  .game-shell {
    width: min(100% - 0.75rem, 1240px);
  }

  .intro {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .toolbar {
    align-items: flex-start;
  }

  #status {
    text-align: left;
  }

  .board-card,
  #game,
  .saved-panel {
    min-height: 460px;
  }

  #game {
    height: 62vh;
  }

  .tray {
    left: -64px;
    width: 112px;
  }
}
