:root {
  color-scheme: light;
  --bg: #1e1e1e;
  --panel: #262626;
  --text: #f0f0f0;
  --muted: #a8a8a8;
  --accent: #4f8ef7;
  --board-light: #eae0c8;
  --board-dark: #7d945d;
  --flash-good: #3fae4b;
  --flash-bad: #d64545;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100dvh;
  padding: 8px 12px;
  gap: 8px;
}

#app-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}

#kind-tabs {
  display: flex;
  gap: 6px;
}

.kind-tab {
  flex: 1;
  padding: 8px 4px;
  min-height: 40px;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.kind-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#pattern-select {
  width: 100%;
  min-height: 40px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #3a3a3a;
  background: var(--panel);
  color: var(--text);
  font-size: 0.95rem;
}

#position-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.95rem;
}

#position-heading {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#position-status {
  white-space: nowrap;
  font-size: 0.85rem;
}

#position-status.status-solved {
  color: var(--flash-good);
}

#position-status.status-help {
  color: var(--accent);
}

#position-counter {
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#pattern-description {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.3em;
  color: var(--muted);
}

#solution-moves {
  flex: 0 0 auto;
  margin: 0;
  min-height: 1.3em;
  padding: 0 2px;
  font-size: 0.85rem;
  color: var(--text);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#board-area {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  position: relative;
}

#board-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  max-width: 100%;
  max-height: 100%;
}

#board-canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  touch-action: manipulation;
}

#error-banner {
  display: none;
}

#error-banner:not([hidden]) {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 16px;
  background: var(--flash-bad);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.95rem;
}

#promotion-menu {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
}

#promotion-menu[hidden] {
  display: none;
}

.promotion-choice {
  width: 56px;
  height: 56px;
  font-size: 2rem;
  line-height: 1;
  border-radius: 10px;
  border: 1px solid #3a3a3a;
  background: var(--panel);
  color: var(--text);
}

.promotion-choice:active {
  background: var(--accent);
  color: #fff;
}

#controls {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#controls button {
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid #3a3a3a;
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}

#controls button:active:not(:disabled) {
  background: var(--accent);
  color: #fff;
}

#controls button:disabled {
  color: #5a5a5a;
  opacity: 0.6;
}

@media (min-width: 700px) {
  #app {
    max-width: 480px;
    margin: 0 auto;
  }
}
