:root {
  --paper: #f6f4ee;
  --paper-shadow: #e7e2d7;
  --ink-blue: #1b3fde;
  --ink-red: #df2f2f;
  --grid-blue: #5467e6;
  --text: #21212b;
  --panel: rgba(255, 255, 255, 0.58);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Neucha", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 18%, #fff8da 0%, transparent 32%),
    radial-gradient(circle at 81% 5%, #e6f0ff 0%, transparent 30%),
    linear-gradient(180deg, #efebe0 0%, #e9e3d4 100%);
  display: grid;
  place-items: center;
  padding: 18px;
}

.game-page {
  width: min(1100px, 100%);
}

.paper-panel {
  position: relative;
  background: var(--paper);
  border: 2px solid #dfdbd0;
  border-radius: 20px;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.12),
    0 4px 0 var(--paper-shadow);
  padding: 20px 20px 16px;
  overflow: hidden;
}

.paper-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(transparent 96%, rgba(155, 145, 126, 0.15) 100%),
    radial-gradient(circle at 0 0, rgba(88, 86, 85, 0.04) 0, transparent 18%),
    radial-gradient(circle at 100% 100%, rgba(88, 86, 85, 0.04) 0, transparent 16%);
  background-size: 100% 4px, 100% 100%, 100% 100%;
  pointer-events: none;
}

.top-bar,
.hud,
.board-wrap,
.controls {
  position: relative;
  z-index: 1;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3.8vw, 2.8rem);
  font-family: "Caveat", "Neucha", cursive;
  letter-spacing: 0.03em;
  color: #153285;
}

.subtitle {
  margin: 0;
  font-size: 1.12rem;
  color: #304472;
}

.hud {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  align-items: start;
}

.turn-chip {
  width: min(238px, 100%);
  height: 44px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 999px;
  border: 2px dashed #2a4bcc;
  background: var(--panel);
  font-size: 1.13rem;
  line-height: 1;
  white-space: nowrap;
  color: #18357f;
}

.turn-chip-prefix {
  display: inline-block;
}

.turn-chip-symbol {
  width: 1.25em;
  height: 1.25em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.18em;
  line-height: 1;
  font-family: "Trebuchet MS", "Segoe UI Symbol", sans-serif;
}

.message {
  font-size: 1.03rem;
  min-height: 1.35em;
  line-height: 1.35;
  color: #3c4562;
}

.online-panel {
  margin-top: 10px;
  padding: 10px;
  border: 2px dashed #b8c4ff;
  border-radius: 12px;
  background: rgba(238, 243, 255, 0.66);
  display: grid;
  gap: 8px;
}

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

.online-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.98rem;
  color: #2f4279;
}

#onlineStatus {
  font-weight: 700;
}

input[type="text"] {
  border: 2px solid #2e4fd0;
  background: #f7f9ff;
  color: #18357f;
  border-radius: 10px;
  padding: 7px 10px;
  font: inherit;
  min-width: 140px;
}

button:disabled,
select:disabled,
input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.board-wrap {
  margin-top: 12px;
  position: relative;
  border: 2px solid #d0d5f5;
  border-radius: 14px;
  background: linear-gradient(180deg, #f3f5ff 0%, #eceffd 100%);
  overflow: hidden;
}

#board,
#fireworks {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 620;
}

#board {
  cursor: crosshair;
  touch-action: auto;
}

#fireworks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.controls {
  margin-top: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.copyright {
  margin: 14px 2px 0;
  font-family: "Caveat", "Neucha", cursive;
  font-size: clamp(1.15rem, 2.6vw, 1.5rem);
  color: #2f4ba3;
  opacity: 0.9;
}

.mode-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #1e377e;
}

select {
  border: 2px solid #2e4fd0;
  background: #f7f9ff;
  color: #18357f;
  border-radius: 10px;
  padding: 7px 10px;
  font: inherit;
}

button {
  border: 2px solid #2e4fd0;
  background: #f7f9ff;
  color: #18357f;
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(28, 53, 144, 0.2);
}

button:active {
  transform: translateY(0);
}

@media (max-width: 1024px) {
  body {
    display: block;
    overflow-y: auto;
    padding: 10px;
  }

  .game-page {
    width: 100%;
    margin: 0 auto;
  }

  .paper-panel {
    padding: 14px 12px;
  }

  .board-wrap {
    width: min(100%, calc(58vh * 900 / 620));
    margin-inline: auto;
  }
}

@media (max-width: 740px) {
  body {
    padding: 8px;
  }

  .paper-panel {
    border-radius: 14px;
    padding: 14px 12px;
  }

  .subtitle {
    font-size: 1rem;
  }

  .message {
    font-size: 0.98rem;
  }

  button {
    flex: 1 1 auto;
  }

  .online-row > * {
    flex: 1 1 auto;
  }

  .mode-picker {
    width: 100%;
    justify-content: space-between;
  }

  .copyright {
    margin-top: 12px;
    text-align: center;
  }

  select {
    flex: 1;
  }
}
