:root {
  --bg: #17191e;
  --bg2: #262a33;
  --fg: #f3f1ec;
  --muted: #a9adb8;
  --card: rgba(30, 33, 40, 0.78);
  --line: rgba(255, 255, 255, 0.12);
  --p0: #f26a00;
  --p1: #1d7cf0;
  --gutter: 16px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 35%, var(--bg2), var(--bg));
  color: var(--fg);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#board {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#board:active {
  cursor: grabbing;
}

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) 0;
  pointer-events: none;
}

.top > * {
  pointer-events: auto;
}

.logo {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.logo .o0 {
  color: var(--p0);
}

.logo .o1 {
  color: var(--p1);
}

.tagline {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chip,
.button {
  font: inherit;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.chip:hover,
.button:hover {
  border-color: rgba(255, 255, 255, 0.35);
}

.button {
  background: var(--fg);
  color: #1b1d22;
  font-weight: 700;
  border: none;
  padding: 10px 18px;
}

.button.ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
  font-weight: 600;
}

.panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 28px);
  width: min(560px, calc(100% - 2 * var(--gutter)));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.scores {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.score {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  border-radius: 10px;
  border: 1px solid transparent;
}

.score.turn {
  border-color: var(--c);
  box-shadow: 0 0 12px -2px var(--c);
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--c);
  box-shadow: 0 0 10px -1px var(--c);
}

.score strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  min-width: 1.4em;
}

.score .name {
  color: var(--muted);
  font-size: 13px;
}

.status {
  margin: 8px 0 0;
  font-size: 15px;
  min-height: 1.4em;
}

.tip {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.actions:empty {
  display: none;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.store {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.store h2 {
  margin: 0 0 4px;
  font-size: 15px;
}

.store p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.store-link:not([href]) {
  background: rgba(255, 255, 255, 0.12);
  color: var(--muted);
  cursor: default;
}

.credits {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 6px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
}

.credits a {
  color: var(--muted);
}

.toast {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  background: rgba(20, 22, 27, 0.9);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 15px;
  opacity: 0;
  transition:
    opacity 0.2s,
    transform 0.2s;
  pointer-events: none;
  max-width: calc(100% - 2 * var(--gutter));
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.panel-title {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.replay {
  margin-top: 8px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon.main {
  width: 48px;
  height: 48px;
  background: var(--fg);
  color: #1b1d22;
  border: none;
}

.icon.main .pause,
.icon.main.playing .play {
  display: none;
}

.icon.main.playing .pause {
  display: block;
}

.seek {
  width: 100%;
  margin: 10px 0 0;
  accent-color: var(--fg);
}

[hidden] {
  display: none !important;
}

/* 広い横長の画面: 板を盤の右に立て、ストアの案内が出ても盤を小さくしない */
@media (min-width: 960px) and (min-aspect-ratio: 5/4) {
  .panel {
    left: auto;
    right: 32px;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    width: 380px;
    max-height: calc(100% - 140px);
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .logo {
    font-size: 22px;
  }
  .score strong {
    font-size: 19px;
  }
  .panel {
    bottom: calc(env(safe-area-inset-bottom) + 24px);
    padding: 10px 12px;
  }
}
