.reserves-actions-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}
.reserves {
  margin-bottom: 0;
}
.actions {
  margin-bottom: 0;
}
.bottom-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 32px;
  margin-top: 18px;
  margin-bottom: 0;
}
.difficulty-select {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.difficulty-select select {
  font-size: 15px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #bbb;
}
.mode-select {
  margin: 10px 0 8px 0;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mode-select select {
  font-size: 15px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #bbb;
}
.timers {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.timer {
  font-size: 15px;
  font-weight: 500;
  color: #333;
}
.timer span.move {
  color: #de4b4b;
}
.timer span.total {
  color: #4977de;
}

.actions {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}
#undo {
  background: #f5b942;
  color: #222;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s;
}
#undo:hover {
  background: #e09c1b;
}
:root {
  --red: #de4b4b;
  --red-light: #f8c5c5;
  --blue: #4977de;
  --blue-light: #c3d3f8;
  --bg: #f5f5f5;
  --text: #1f1f1f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 32px;
  width: min(960px, calc(100vw - 32px));
  align-items: start;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: #ddd;
  padding: 10px;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  width: min(70vw, 70vh, 480px);
  aspect-ratio: 1;
}

.cell {
  position: relative;
  background: #fff;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 14px;
  transition: transform 0.1s ease;
  aspect-ratio: 1;
}

.cell.selected {
  outline: 3px solid rgba(222, 75, 75, 0.5);
}

.cell.selected.blue {
  outline: 3px solid rgba(73, 119, 222, 0.5);
}

.cell:focus-visible,
.cell:hover {
  transform: translateY(-2px);
  outline: 3px solid rgba(73, 119, 222, 0.35);
}

.cell .stack {
  display: flex;
  flex-direction: column;
  width: 80%;
  align-items: center;
}

.token {
  width: 100%;
  border-radius: 999px;
  text-align: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  margin: 4px 0;
  padding: 6px 0;
  pointer-events: none;
}

.token.small {
  max-width: 60%;
}

.token.medium {
  max-width: 80%;
}

.token.large {
  max-width: 100%;
}

.token.red {
  background: linear-gradient(140deg, var(--red), var(--red-light));
}

.token.blue {
  background: linear-gradient(140deg, var(--blue), var(--blue-light));
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 360px;
}

.sidebar h1 {
  margin: 0;
  font-size: 24px;
}

.status {
  margin: 0;
  font-weight: 600;
}

.reserves {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.reserve h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reserve button {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  transition: transform 0.1s ease, background 0.1s ease;
}

.reserve button.selected {
  transform: translateY(-2px);
  background: rgba(73, 119, 222, 0.2);
}

.reserve button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#reset {
  align-self: flex-start;
  padding: 8px 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: #333;
  color: #fff;
  cursor: pointer;
}

#reset:hover {
  background: #000;
}

.rules {
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.rules h2 {
  margin-top: 0;
  font-size: 18px;
}

.rules ol {
  padding-left: 18px;
  margin: 0;
}

.rules li {
  margin-bottom: 6px;
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
    gap: 24px;
    width: min(540px, 100%);
  }

  .board {
    justify-self: center;
    width: min(80vw, 460px);
    order: -1 !important;
  }

  body {
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .board {
    width: 100%;
  }

  .sidebar {
    max-width: none;
  }

  .reserve button,
  #reset {
    width: 100%;
  }
}
