:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --ink: #111827;
  --muted: #5f6b7a;
  --line: #d9e0ea;
  --panel: #ffffff;
  --surface: #f4f7fb;
  --surface-strong: #e8edf5;
  --shadow: 0 18px 45px rgba(30, 41, 59, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(244, 247, 251, 0.94)),
    radial-gradient(circle at 10% 15%, rgba(56, 189, 248, 0.14), transparent 28rem),
    radial-gradient(circle at 90% 5%, rgba(245, 158, 11, 0.13), transparent 26rem),
    #f4f7fb;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #2563eb;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2.15rem;
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.score-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.score-strip span,
.selected-label {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: #334155;
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
  font-weight: 700;
}

.score-strip .warning {
  border-color: #f59e0b;
  color: #9a3412;
  background: #fff7ed;
}

.score-strip .success {
  border-color: #16a34a;
  color: #166534;
  background: #f0fdf4;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(340px, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.panel,
.game-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.game-panel {
  padding: 18px;
  min-width: 0;
}

.panel-title,
.board-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.board-actions {
  margin-bottom: 16px;
}

.status-message {
  min-height: 20px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.status-message.error {
  color: #b91c1c;
}

.status-message.success {
  color: #15803d;
}

.field-grid {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.field-grid.two {
  grid-template-columns: 1fr 1fr;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 800;
}

input {
  width: 100%;
  height: 42px;
  border: 1px solid #c9d3e2;
  border-radius: 7px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.shape-settings {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.shape-settings label {
  grid-template-columns: 64px 1fr;
  align-items: center;
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 1px solid transparent;
  border-radius: 7px;
  min-height: 40px;
  padding: 0 12px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  color: #fff;
  background: #111827;
}

.primary-button:hover {
  background: #020617;
}

.secondary-button {
  color: #1f2937;
  border-color: #c9d3e2;
  background: #fff;
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.ghost-button {
  color: #334155;
  border-color: var(--line);
  background: transparent;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.board-wrap {
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 1px solid var(--surface-strong);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(238, 242, 247, 0.82)),
    #fff;
}

.board {
  --cols: 7;
  --rows: 7;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 680px);
  aspect-ratio: var(--cols) / var(--rows);
  border: 5px solid #111827;
  padding: 6px;
  background: #ffffff;
  touch-action: manipulation;
}

.board-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #f8fafc;
  transition:
    transform 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

.board-cell.filled {
  border-color: var(--piece-border);
  background: var(--piece-color);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.48),
    inset 0 0 0 4px var(--piece-border);
}

.board-cell.selected {
  z-index: 1;
  outline: 3px solid #111827;
  outline-offset: -3px;
}

.board-cell.hover-ok {
  transform: scale(0.96);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.7),
    inset 0 0 0 4px #16a34a;
}

.board-cell.hover-bad {
  transform: scale(0.96);
  box-shadow: inset 0 0 0 4px #dc2626;
}

.piece-tray {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding-right: 3px;
}

.piece-card {
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 92px;
  border: 2px solid var(--piece-border);
  border-radius: 8px;
  padding: 10px 8px 9px;
  background: #ffffff;
  user-select: none;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    opacity 120ms ease;
}

.piece-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.piece-card.selected {
  box-shadow:
    0 0 0 3px #111827,
    0 12px 28px rgba(15, 23, 42, 0.14);
}

.piece-card.placed {
  opacity: 0.42;
}

.piece-shape {
  display: grid;
  grid-template-columns: repeat(var(--shape-cols), 22px);
  grid-template-rows: repeat(var(--shape-rows), 22px);
  gap: 3px;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.piece-cell {
  width: 22px;
  height: 22px;
  border: 2px solid var(--piece-border);
  border-radius: 4px;
  background: var(--piece-color);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.piece-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #334155;
  font-size: 0.8rem;
  font-weight: 800;
}

.piece-state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.piece-card.placed .piece-state-dot {
  background: #16a34a;
}

.win-banner {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  transform: translate(-50%, 120px);
  border: 1px solid #86efac;
  border-radius: 999px;
  padding: 12px 22px;
  color: #14532d;
  background: #f0fdf4;
  box-shadow: 0 18px 45px rgba(21, 128, 61, 0.18);
  font-size: 1rem;
  font-weight: 900;
  transition: transform 180ms ease;
}

body.won .win-banner {
  transform: translate(-50%, 0);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 240px minmax(340px, 1fr);
  }

  .pieces-panel {
    grid-column: 1 / -1;
  }

  .piece-tray {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding: 18px 0;
  }

  .topbar,
  .board-actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 1.75rem;
  }

  .score-strip,
  .action-buttons {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .board-wrap {
    min-height: auto;
    padding: 8px;
  }

  .board {
    gap: 3px;
    border-width: 4px;
    padding: 5px;
  }

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