:root {
  --bg: #f4f8fb;
  --paper: #ffffff;
  --ink: #172638;
  --muted: #617284;
  --line: #d5e0e8;
  --blue: #143a5a;
  --blue-soft: #e7f0f7;
  --accent: #008080;
  --accent-soft: #e2f5f3;
  --danger: #b42318;
  --shadow: 0 14px 30px rgba(23, 38, 56, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f8fbfd 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.7;
}

button,
textarea {
  font: inherit;
}

.page {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 44px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 16px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
  text-decoration: underline;
}

.hero,
.panel,
.board-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.28fr);
  gap: 20px;
  align-items: end;
  padding: 24px;
}

.hero-badge {
  display: inline-flex;
  margin: 0 0 10px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  line-height: 1.3;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.hero-text,
.panel-heading p,
.key-list,
.room-list,
.result-panel p {
  color: var(--muted);
}

.hero-score {
  padding: 16px;
  border: 1px solid #bfd8e9;
  border-radius: 14px;
  background: #f7fbff;
}

.hero-score span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.hero-score strong {
  display: block;
  margin-top: 6px;
  font-size: 1.15rem;
  line-height: 1.45;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.board-panel,
.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.status-chip {
  min-width: 120px;
  height: fit-content;
  padding: 7px 11px;
  border: 1px solid #bfd8e9;
  border-radius: 999px;
  background: #f7fbff;
  color: var(--blue);
  font-weight: 800;
  text-align: center;
  font-size: 0.86rem;
}

.canvas-wrap {
  width: min(100%, 72vh, 720px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border: 1px solid #b7cbd9;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  touch-action: none;
  background: #fff;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

button {
  min-height: 44px;
  border: 1px solid #b8c7d2;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.primary-button,
#lockButton,
#downloadButton {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary-button:hover,
#lockButton:hover,
#downloadButton:hover,
.primary-button:focus-visible,
#lockButton:focus-visible,
#downloadButton:focus-visible {
  color: #fff;
  opacity: 0.92;
}

.key-list {
  margin: 14px 0 0;
  padding-left: 20px;
  font-size: 0.9rem;
}

.stats dl {
  display: grid;
  gap: 9px;
  margin: 0;
}

.stats dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #edf2f5;
}

.stats dt {
  color: var(--muted);
}

.stats dd {
  margin: 0;
  font-weight: 800;
}

.room-list {
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 0.9rem;
}

.share-panel textarea {
  width: 100%;
  resize: vertical;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
}

.mobile-pad {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.mobile-pad button:nth-child(4),
.mobile-pad button:nth-child(5) {
  grid-column: span 1;
}

@media (max-width: 960px) {
  .hero,
  .game-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 14px, 1180px);
    padding: 14px 0 28px;
  }

  .hero,
  .panel,
  .board-panel {
    padding: 14px;
    border-radius: 14px;
  }

  .panel-heading {
    flex-direction: column;
  }

  .button-grid,
  .mobile-pad {
    grid-template-columns: 1fr;
  }

  .mobile-pad {
    display: grid;
  }

  .status-chip {
    width: 100%;
  }
}
