:root {
  --bg1: #eaf4ff;          /* 背景グラデ start (やさしい水色) */
  --bg2: #dfefff;          /* 背景グラデ end   (もう少し青) */
  --panel: #ffffff;        /* パネル */
  --panel-tint: #f2f8ff;
  --ink: #1e3a5f;          /* 文字 (ネイビー寄り) */
  --ink-mute: #7b8fb0;
  --border: #dbeafe;
  --accent: #7dd3fc;       /* スカイブルー */
  --accent-2: #a5b4fc;     /* 藤色 */
  --warn: #fb923c;         /* ピーチ */
  --field: #1e3a5f;        /* プレイフィールド (ネイビー、夜空感) */
  --shadow-soft: 0 6px 20px rgba(100, 150, 200, 0.18);
  --shadow-soft-lg: 0 12px 40px rgba(100, 150, 200, 0.22);
  --font: "M PLUS Rounded 1c", -apple-system, BlinkMacSystemFont,
    "Hiragino Sans", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 10% 0%,  #c7e4ff 0%, transparent 60%),
    radial-gradient(900px 700px at 100% 100%, #d6e9ff 0%, transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  min-height: 100vh;
  letter-spacing: 0.02em;
}

.app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

h1 {
  font-size: 32px;
  font-weight: 900;
  margin: 0 0 18px;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #0369a1 0%, #4338ca 60%, #6d28d9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* background-clip 時は text-shadow が透けるので filter で影を付ける */
  filter:
    drop-shadow(0 1px 0 rgba(255, 255, 255, 0.95))
    drop-shadow(0 2px 6px rgba(30, 58, 95, 0.18));
}

h2 {
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

.board-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.player-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--ink-mute);
  background: white;
  border-radius: 999px;
  padding: 3px 12px;
  box-shadow: var(--shadow-soft);
}

canvas#board {
  background: var(--field);
  border: 4px solid #fff;
  border-radius: 20px;
  image-rendering: pixelated;
  touch-action: none;
  box-shadow: var(--shadow-soft-lg), inset 0 0 0 2px #93c5fd;
}

canvas#opponent-board {
  background: var(--field);
  border: 3px solid #fff;
  border-radius: 14px;
  image-rendering: pixelated;
  box-shadow: var(--shadow-soft), inset 0 0 0 1px #93c5fd;
}

canvas#next {
  background: var(--field);
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(120, 90, 140, 0.12);
}

canvas.garbage-preview {
  display: block;
  background: transparent;
}

.opp-info {
  font-size: 12px;
  color: var(--ink);
  display: flex;
  gap: 8px;
  background: white;
  border-radius: 12px;
  padding: 6px 10px;
  box-shadow: var(--shadow-soft);
}
.opp-info .label { color: var(--ink-mute); margin-right: 4px; }

.panel {
  flex: 0 0 auto;
  width: 168px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--panel-tint);
  border: 2px solid #fff;
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.score, .chain {
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 900;
  color: var(--ink);
}

.garbage-row {
  display: flex;
  gap: 8px;
}
.gb {
  flex: 1;
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 6px 8px;
  font-size: 11px;
  text-align: center;
}
.gb .label {
  display: block;
  color: var(--ink-mute);
  margin-bottom: 2px;
}
.gb span:not(.label) {
  font-size: 20px;
  font-weight: 900;
  color: var(--warn);
}

.controls ul {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.75;
  color: var(--ink);
}

button {
  background: linear-gradient(180deg, #bae6fd 0%, #7dd3fc 100%);
  color: #0c4a6e;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 900;
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow:
    0 4px 0 #0ea5e9,
    0 8px 16px rgba(14, 165, 233, 0.25);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
button:hover { filter: brightness(1.05); }
button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0ea5e9, 0 3px 8px rgba(14, 165, 233, 0.2);
}

button.secondary {
  background: white;
  color: var(--ink);
  box-shadow:
    0 3px 0 #c5d9ee,
    0 6px 12px rgba(120, 150, 180, 0.18);
}
button.secondary:active {
  box-shadow: 0 1px 0 #c5d9ee, 0 3px 8px rgba(120, 150, 180, 0.15);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: 0 2px 0 #0ea5e9, 0 4px 8px rgba(14, 165, 233, 0.15);
}

.status {
  margin-top: 14px;
  min-height: 1.4em;
  color: var(--warn);
  font-weight: 700;
  text-align: center;
}

/* ===== オーバーレイ ===== */
.overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(600px 400px at 50% 40%, rgba(186, 230, 253, 0.55) 0%, transparent 70%),
    rgba(224, 237, 252, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(10px);
}
.overlay.hidden { display: none; }

.menu-box {
  background: white;
  border: 3px solid #fff;
  border-radius: 24px;
  padding: 28px 24px;
  min-width: 300px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  box-shadow:
    0 20px 60px rgba(120, 170, 210, 0.35),
    inset 0 0 0 1px rgba(125, 211, 252, 0.35);
}

.menu-box h2 {
  font-size: 22px;
  font-weight: 900;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0.05em;
  margin: 0;
  background: linear-gradient(90deg, #0ea5e9, #6366f1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.menu-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.menu-mascot {
  width: 88px;
  height: 88px;
  object-fit: contain;
  animation: mascot-jump 1.6s ease-in-out infinite;
  transform-origin: center bottom;
}
@keyframes mascot-jump {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  40%      { transform: translateY(-10px) scale(1, 1); }
  50%      { transform: translateY(-10px) scale(1.05, 0.95); }
  60%      { transform: translateY(-10px) scale(1, 1); }
  85%      { transform: translateY(0) scale(1.15, 0.85); }
}
.menu-box p {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}
.menu-box p.small {
  font-size: 12px;
  color: var(--ink-mute);
}
.menu-box input {
  font-size: 26px;
  font-weight: 900;
  font-family: "SFMono-Regular", Menlo, monospace;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  padding: 12px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--panel-tint);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.menu-box input:focus {
  border-color: var(--accent);
}

.room-code {
  font-family: "SFMono-Regular", Menlo, monospace;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0.3em;
  background: linear-gradient(180deg, #fff1f5 0%, #fbcfe8 100%);
  border: 2px solid #fff;
  border-radius: 18px;
  padding: 16px;
  color: #9d174d;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7);
  user-select: all;
  box-shadow: var(--shadow-soft);
}

.hidden { display: none !important; }

@media (max-width: 720px) {
  .layout { flex-direction: column; align-items: center; }
  .panel { width: 100%; max-width: 336px; }
  canvas#board { max-width: 100%; height: auto; }
}
