:root {
  color-scheme: light;
  --paper: #f5f0e8;
  --ink: #22313a;
  --muted: #6b7b80;
  --panel: #fffaf2;
  --line: #232b31;
  --accent: #d65138;
  --accent-2: #217c7e;
  --soft: #d9d1c4;
  --shadow: 0 16px 42px rgba(35, 43, 49, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  touch-action: manipulation;
}

body {
  min-height: 100svh;
  display: grid;
  place-items: center;
}

button {
  border: 1px solid #cfc4b6;
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  min-height: 44px;
  font: 700 15px/1 system-ui, sans-serif;
  padding: 0 14px;
  box-shadow: 0 2px 0 rgba(34, 49, 58, 0.12);
}

button:active {
  transform: translateY(1px);
  box-shadow: none;
}

.app-shell {
  width: min(100vw, 820px);
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 8vw, 46px);
  line-height: 0.95;
  letter-spacing: 0;
}

.topbar p,
.note p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.version {
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
  padding-bottom: 4px;
}

.board-wrap {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
}

canvas {
  display: block;
  width: min(100%, 72svh, 760px);
  aspect-ratio: 1;
  height: auto;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  user-select: none;
  -webkit-user-select: none;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) translateY(8px);
  max-width: calc(100% - 28px);
  padding: 10px 13px;
  border-radius: 8px;
  background: rgba(34, 49, 58, 0.94);
  color: #fffdf8;
  font-weight: 800;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.controls {
  display: grid;
  gap: 9px;
}

.mode-tabs,
.actions,
.level-tabs {
  display: grid;
  gap: 8px;
}

.mode-tabs {
  grid-template-columns: repeat(3, 1fr);
}

.actions {
  grid-template-columns: 52px 1fr 1fr 1fr;
}

.level-tabs,
.difficulty-tabs {
  grid-template-columns: repeat(3, 1fr);
}

.difficulty-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fffdf8;
}

.note {
  min-height: 34px;
}

@media (min-width: 780px) {
  .app-shell {
    min-height: 100vh;
    grid-template-columns: 1fr 230px;
    grid-template-rows: auto 1fr auto;
    align-items: start;
  }

  .topbar,
  .board-wrap,
  .note {
    grid-column: 1;
  }

  .controls {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
  }

  canvas {
    width: min(68vh, 720px);
  }
}
