:root {
  color-scheme: light;
  --bg-top: #eef6f4;
  --bg-bottom: #dfe6d8;
  --panel: rgba(255, 252, 248, 0.78);
  --panel-line: rgba(124, 122, 146, 0.14);
  --ink: #43394a;
  --muted: #756b7d;
  --accent: #d96ea7;
  --accent-soft: #f5d8ea;
  --shadow: rgba(83, 59, 78, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 226, 239, 0.8), transparent 24%),
    radial-gradient(circle at 82% 12%, rgba(204, 229, 238, 0.8), transparent 23%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(10px);
  opacity: 0.45;
}

body::before {
  width: 220px;
  height: 220px;
  left: -30px;
  bottom: 12vh;
  background: rgba(255, 209, 231, 0.5);
}

body::after {
  width: 280px;
  height: 280px;
  right: -70px;
  top: 8vh;
  background: rgba(196, 224, 232, 0.55);
}

.app {
  width: min(560px, calc(100vw - 16px));
  height: 100dvh;
  margin: 0 auto;
  padding: 8px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-head,
.play-panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 32px;
  box-shadow: 0 28px 70px var(--shadow);
  backdrop-filter: blur(10px);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 7vw, 2.25rem);
  line-height: 1;
  letter-spacing: 0.02em;
}

.play-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.board-frame {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 248, 251, 0.42)),
    rgba(244, 239, 245, 0.65);
  border: 1px solid rgba(110, 97, 123, 0.1);
}

#gameCanvas {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 420 / 680;
  border-radius: 22px;
  background: linear-gradient(180deg, #eff6f6 0%, #dce6ea 100%);
  box-shadow: inset 0 0 0 1px rgba(90, 87, 102, 0.08);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.game-over {
  position: absolute;
  inset: 24px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  border-radius: 22px;
  background: rgba(255, 248, 250, 0.72);
  backdrop-filter: blur(8px);
}

.game-over[hidden] {
  display: none !important;
}

.game-over-title {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 700;
}

.game-over-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background:
    linear-gradient(180deg, #d97bb0, #c35d94);
  box-shadow:
    0 10px 24px rgba(192, 95, 147, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow:
    0 14px 26px rgba(192, 95, 147, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

@media (max-width: 900px) {
  .app {
    width: min(100vw - 14px, 560px);
  }
}

@media (max-width: 520px) {
  body {
    background:
      radial-gradient(circle at 50% -10%, rgba(255, 226, 239, 0.7), transparent 38%),
      linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  }

  .app {
    width: min(100vw - 10px, 520px);
    padding: 6px 0 8px;
  }

  .page-head,
  .play-panel {
    border-radius: 20px;
  }

  .page-head {
    gap: 10px;
    padding: 10px 12px;
  }

  button {
    width: auto;
    flex: 0 0 auto;
  }

  .board-frame {
    padding: 6px;
  }

  #gameCanvas {
    width: auto;
    height: 100%;
  }
}
