:root {
  --bg: #101820;
  --surface: #1d2733;
  --surface-strong: #263340;
  --text: #f3f4f6;
  --text-muted: #b0bec5;
  --accent: #8fd3fe;
  --accent-strong: #5eb6ff;
  --success: #5fd89d;
  --warning: #f4b860;
  --danger: #ef6b73;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: radial-gradient(circle at top, #233a55 0%, var(--bg) 55%);
  color: var(--text);
}

.app-shell {
  max-width: 1024px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 18px;
}

header h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
}

header p {
  margin: 10px auto 0;
  max-width: 700px;
  color: var(--text-muted);
}

.language-selector {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.language-selector label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.language-selector select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 4px 8px;
  color: var(--text);
  font-size: 0.9rem;
}

.score-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
}

.score-panel div {
  font-size: 0.94rem;
}

main {
  display: grid;
  gap: 20px;
}

.game-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.board-panel {
  background: var(--surface);
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.board-panel h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.stack-display {
  min-height: 60px;
  max-height: 200px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(6, 56px);
  justify-content: start;
  gap: 10px;
}

.tile-card {
  display: grid;
  place-items: center;
  width: 56px;
  min-width: 56px;
  height: 56px;
  min-height: 56px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid transparent;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tile-card:hover:not(.disabled) {
  transform: translateY(-1px);
}

.tile-card.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tile-card.selected {
  background: rgba(94, 182, 255, 0.18);
  border-color: var(--accent-strong);
}

.tile-card.valid {
  border-color: rgba(94, 182, 255, 0.55);
}

.tile-card.invalid {
  opacity: 0.25;
}

.stack-display .tile-card {
  min-width: 56px;
}

.controls-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.control-block {
  background: var(--surface);
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.control-block h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.05rem;
}

#next-message {
  margin: 0 0 14px;
  color: var(--text-muted);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button-row button,
.action-panel button,
#save-score-button {
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #0b1120;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.92rem;
  transition: transform 0.15s ease, background 0.15s ease;
}

.button-row button:disabled,
#save-score-button:disabled,
.tile-card.disabled {
  background: rgba(255, 255, 255, 0.08);
  color: #7c8a98;
  cursor: not-allowed;
}

.button-row button:hover:not(:disabled),
.action-panel button:hover,
#save-score-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.summary-list {
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--text-muted);
}

.summary-list li {
  margin-bottom: 6px;
}

.action-panel {
  display: flex;
  justify-content: center;
}

.action-panel button {
  width: 100%;
  max-width: 300px;
}

.end-screen {
  background: rgba(255, 255, 255, 0.04);
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hidden {
  display: none;
}

.end-screen.hidden {
  display: none;
}

.end-screen h2 {
  margin-top: 0;
}

.end-screen label {
  display: block;
  margin: 14px 0 8px;
  color: var(--text-muted);
}

.end-screen input {
  width: 100%;
  max-width: 260px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

#highscore-panel {
  margin-top: 14px;
}

#highscore-panel h3 {
  margin: 0 0 12px;
}

#highscore-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  color: var(--text);
}

#highscore-table th,
#highscore-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#highscore-table th {
  color: var(--accent);
  font-weight: 600;
}

#highscore-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

#highscore-table tr.highlighted {
  background: rgba(94, 182, 255, 0.18);
}

/* Shape styles for tiles */
.tile-shape {
  width: 20px;
  height: 20px;
  position: relative;
}

.tile-shape.square {
  width: 20px;
  height: 20px;
  background: currentColor;
  border-radius: 2px;
}

.tile-shape.circle {
  width: 20px;
  height: 20px;
  background: currentColor;
  border-radius: 50%;
}

.tile-shape.triangle {
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 20px solid currentColor;
  margin: -3px 0 0 0;
}

/* Size variations for small/large tiles */
.tile-shape.large {
  width: 32px;
  height: 32px;
}

.tile-shape.large.square {
  width: 32px;
  height: 32px;
  border-radius: 3px;
}

.tile-shape.large.circle {
  width: 32px;
  height: 32px;
}

.tile-shape.large.triangle {
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-bottom: 32px solid currentColor;
  margin: -4px 0 0 0;
}

@media (max-width: 900px) {
  .game-board,
  .controls-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  header h1 {
    font-size: clamp(1.7rem, 7vw, 2.4rem);
  }

  .score-panel {
    gap: 10px;
    padding: 12px 14px;
  }

  .board-panel,
  .control-block,
  .end-screen {
    padding: 14px;
  }

  .tile-grid {
    grid-template-columns: repeat(6, 44px);
    justify-content: start;
    gap: 10px;
  }

  .tile-card {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 7px;
    border-radius: 10px;
  }

  .stack-display {
    min-height: 90px;
    display: grid;
    grid-template-columns: repeat(6, 44px);
    justify-content: start;
    gap: 10px;
    padding: 8px;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
  }

  .stack-display .tile-card {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .button-row,
  .action-panel {
    gap: 8px;
  }

  .button-row button,
  .action-panel button,
  #save-score-button {
    padding: 9px 12px;
    font-size: 0.88rem;
  }

  .summary-list li,
  #next-message,
  .board-panel h2,
  .control-block h2 {
    font-size: 0.88rem;
  }

  .end-screen label {
    margin: 12px 0 6px;
  }

  .end-screen input {
    padding: 8px 10px;
  }

  .tile-shape {
    width: 10px;
    height: 10px;
  }

  .tile-shape.large {
    width: 15px;
    height: 15px;
  }

  .tile-shape.square,
  .tile-shape.circle {
    width: 10px;
    height: 10px;
  }

  .tile-shape.large.square,
  .tile-shape.large.circle {
    width: 15px;
    height: 15px;
  }

  .tile-shape.triangle {
    border-left-width: 5px;
    border-right-width: 5px;
    border-bottom-width: 10px;
  }

  .tile-shape.large.triangle {
    border-left-width: 7px;
    border-right-width: 7px;
    border-bottom-width: 15px;
  }
}

