:root {
  --bg: #fff9f2;
  --cream: #fffdf8;
  --panel: #ffffff;
  --border: #ffe2c8;
  --text: #553f2e;
  --muted: #b0957c;
  --accent: #ffa35c;
  --accent-2: #ff8552;
  --green: #1e7d46;
  --green-2: #2b8f54;
  --green-3: #46a06b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background-color: var(--bg);
  background-image: linear-gradient(rgba(18, 14, 38, 0.72), rgba(18, 14, 38, 0.78)), url('assets/img/bg.png');
  background-size: cover;
  background-attachment: fixed;
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  line-height: 1.6;
}

.site-header {
  position: relative;
  text-align: center;
  padding: 34px 16px 8px;
}

.lang-select {
  position: absolute;
  top: 12px;
  right: 14px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}

.site-header h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.04em;
  color: var(--accent-2);
}

.logo {
  display: inline-block;
  width: 26px;
  height: 26px;
  margin-right: 6px;
  vertical-align: -5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #666, #111 70%);
  box-shadow: inset -3px -3px 6px rgba(0,0,0,.35), 0 2px 5px rgba(0,0,0,.25);
}

.site-header .sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 22px 16px 40px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 10px 26px rgba(255, 163, 92, 0.14);
  padding: 20px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.score {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.95rem;
  flex: 1;
}

.score b {
  margin-left: auto;
  font-size: 1.15rem;
  color: var(--text);
}

.disc {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
}

.disc.black {
  background: radial-gradient(circle at 35% 30%, #666, #111 72%);
  box-shadow: inset -2px -3px 5px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.3);
}

.disc.white {
  background: radial-gradient(circle at 35% 30%, #fff, #d9d9d9 75%);
  box-shadow: inset -2px -3px 5px rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.2);
}

.status {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  min-height: 1.6em;
  margin-bottom: 14px;
  color: var(--accent-2);
}

.status.game-over {
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(30, 125, 70, 0.28);
}

.board-wrap {
  display: flex;
  justify-content: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(88vw, 440px);
  aspect-ratio: 1;
  background: var(--green);
  border-radius: 14px;
  padding: 6px;
  gap: 4px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.15), 0 8px 20px rgba(30, 125, 70, 0.35);
  user-select: none;
}

.cell {
  background: var(--green-2);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background 0.12s ease;
}

.cell:hover { background: var(--green-3); }
.board.locked .cell { cursor: default; }

.cell .disc {
  width: 86%;
  height: 86%;
  animation: pop 0.22s ease;
}

.cell .disc.last {
  outline: 3px solid #ffd54d;
  outline-offset: -1px;
}

.cell.hint::after {
  content: "";
  width: 36%;
  height: 36%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pop {
  0% { transform: scale(0.4); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.controls {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-group label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  background: var(--cream);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  flex: 1;
  min-width: 90px;
}

button:hover {
  border-color: var(--accent);
  background: #fff3e4;
}

button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 133, 82, 0.35);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 133, 82, 0.35);
  flex: 2;
}

button.primary:hover { filter: brightness(1.06); }

footer {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px 40px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 480px) {
  .panel { padding: 14px; }
  .score { padding: 6px 12px; font-size: 0.88rem; }
}

/* ================================================================== *
 *  スマホ1画面対応: スクロールなしで盤面全体が収まるようにする
 * ================================================================== */
@media (max-width: 760px), (max-height: 520px) {
  html, body { height: 100%; }

  body {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    overscroll-behavior: none;
    height: 100vh;
  }

  @supports (height: 100dvh) {
    body { height: 100dvh; }
  }

  a[href="https://ai.noela.moe/"] {
    top: 6px;
    left: 6px;
    font-size: 0.68rem;
    padding: 3px 9px;
  }

  .lang-select {
    top: 6px;
    right: 8px;
    padding: 4px 8px;
    font-size: 0.72rem;
    border-radius: 8px;
  }

  .site-header {
    flex: none;
    padding: 30px 12px 2px;
  }

  .site-header h1 {
    font-size: 1.2rem;
  }

  .logo {
    width: 20px;
    height: 20px;
    vertical-align: -4px;
  }

  .site-header .sub {
    font-size: 0.78rem;
    margin-top: 2px;
  }

  main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    padding: 4px 10px 6px;
  }

  .panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 12px;
    gap: 6px;
    overflow: hidden;
  }

  .score-row,
  .status,
  .controls {
    flex: none;
  }

  .score-row {
    margin-bottom: 4px;
    gap: 8px;
  }

  .score {
    padding: 5px 10px;
    font-size: 0.82rem;
    gap: 6px;
  }

  .score b {
    font-size: 1rem;
  }

  .disc {
    width: 18px;
    height: 18px;
  }

  .status {
    margin-bottom: 2px;
    font-size: 0.9rem;
    min-height: 1.4em;
  }

  .board-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .board {
    /* 正方形を保ったまま、横幅と縦幅の両方に収める */
    width: min(88vw, 460px, 100%);
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1;
    padding: 5px;
    gap: 3px;
    border-radius: 12px;
  }

  .cell {
    border-radius: 5px;
  }

  .controls {
    margin-top: 6px;
    gap: 6px;
  }

  .control-group label {
    font-size: 0.72rem;
    margin-bottom: 3px;
  }

  button {
    padding: 6px 8px;
    font-size: 0.78rem;
    min-width: 0;
    touch-action: manipulation;
  }

  footer {
    flex: none;
    padding: 0 12px 8px;
    font-size: 0.72rem;
    width: 100%;
    margin: 0 auto;
  }
}

/* 横持ちスマホなど高さが低い場合: ヘッダーとフッターを消して盤面を優先 */
@media (max-height: 520px) {
  .site-header {
    display: none;
  }

  .lang-select {
    display: none;
  }

  .board {
    width: min(70vh, 460px, 100%);
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1;
  }

  .board-wrap { flex: 1; }
  .score-row { margin-bottom: 2px; }
  .score { padding: 4px 8px; font-size: 0.76rem; }
  .status { font-size: 0.8rem; }

  .status.game-over {
    font-size: 0.78rem;
    padding: 4px 10px;
  }

  .control-group label { font-size: 0.64rem; }
  button { padding: 5px 6px; font-size: 0.72rem; }
  footer { display: none; }
  main { padding-top: 2px; }
  .panel { padding: 10px; gap: 4px; }
}
