:root {
  --ink: #3d2a45;
  --muted: #8a6a7a;
  --pink: #ff6b9d;
  --cream: #fff7fb;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Jua", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 255, 255, 0.75), transparent 45%),
    linear-gradient(180deg, #ffc1d8 0%, #c8e9ff 50%, #ffe8f5 100%);
}

body {
  min-height: 100dvh;
}

.app {
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.home,
.link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.scores {
  display: flex;
  gap: 8px;
}

.score-box {
  background: rgba(255, 255, 255, 0.78);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  box-shadow: 0 3px 0 rgba(200, 120, 150, 0.18);
}

.hero-bit {
  text-align: center;
  margin: 4px 0 6px;
  flex-shrink: 0;
}

.hero-bit h1 {
  margin: 0;
  font-family: "Bagel Fat One", "Jua", cursive;
  font-weight: 400;
  font-size: 26px;
  color: var(--pink);
  text-shadow: 0 3px 0 #fff;
}

.hero-bit p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.meta-row {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.meta-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.meta-stats {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.meta-slot canvas {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  box-shadow: 0 4px 0 rgba(200, 120, 150, 0.18);
}

.mini-stat {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 6px 10px;
  min-width: 64px;
  box-shadow: 0 3px 0 rgba(200, 120, 150, 0.14);
}

.mini-stat b {
  color: var(--pink);
  font-size: 16px;
}

.mini-stat.soft b {
  color: #5b9fff;
}

.overlay-thumb {
  border-radius: 22px;
  box-shadow: 0 8px 0 rgba(200, 80, 140, 0.28);
}

.board-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: min(100%, calc(72dvh * 0.5), 420px);
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #c8e9ff, #ffd6e8);
  box-shadow:
    0 10px 0 rgba(200, 120, 160, 0.28),
    0 16px 36px rgba(180, 80, 140, 0.18);
  border: 3px solid rgba(255, 255, 255, 0.85);
}

#game {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  aspect-ratio: 1 / 2;
}

.pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 10px;
  flex-shrink: 0;
}

.pad-btn {
  border: none;
  border-radius: 14px;
  min-height: 46px;
  font-family: inherit;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(180deg, #ff9ec4, var(--pink));
  box-shadow: 0 5px 0 #d93f74;
  cursor: pointer;
}

.pad-btn.wide {
  grid-column: span 2;
  font-size: 15px;
}

.pad-btn.accent {
  background: linear-gradient(180deg, #9ed4ff, #5b9fff);
  box-shadow: 0 5px 0 #2f6fd4;
}

.pad-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #d93f74;
}

.pad-btn.accent:active {
  box-shadow: 0 2px 0 #2f6fd4;
}

.hint {
  text-align: center;
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  flex-shrink: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: rgba(55, 35, 55, 0.55);
  backdrop-filter: blur(8px);
  text-align: center;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.badge {
  background: linear-gradient(180deg, #ff8ab5, var(--pink));
  color: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  box-shadow: 0 4px 0 #e03f74;
}

.badge.soft {
  background: linear-gradient(180deg, #9ed4ff, #5b9fff);
  box-shadow: 0 4px 0 #2f6fd4;
}

.overlay h2 {
  margin: 0;
  font-family: "Bagel Fat One", "Jua", cursive;
  font-weight: 400;
  font-size: 32px;
  color: #fff;
}

.overlay p {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.5;
}

.btn {
  margin-top: 6px;
  border: none;
  border-radius: 999px;
  padding: 14px 32px;
  font-family: inherit;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(180deg, #ff9ec4, var(--pink));
  box-shadow: 0 6px 0 #d93f74;
  cursor: pointer;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #d93f74;
}

.btn.ghost {
  background: linear-gradient(180deg, #9ed4ff, #5b9fff);
  box-shadow: 0 6px 0 #2f6fd4;
}

.btn.ghost:active {
  box-shadow: 0 3px 0 #2f6fd4;
}

.btn.soft {
  background: linear-gradient(180deg, #ffe27a, #e0b040);
  box-shadow: 0 6px 0 #c49020;
  color: #4a3420;
}

.btn.soft:active {
  box-shadow: 0 3px 0 #c49020;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.mode-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}

.mode-btns .btn {
  margin-top: 0;
  min-width: 140px;
}

.hidden {
  display: none !important;
}

.rank-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(280px, 100%);
  margin-top: 4px;
}

.rank-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.88);
}

.rank-input {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 18px;
  text-align: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 0 rgba(200, 120, 150, 0.25);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.rank-input:focus {
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.7),
    0 4px 0 rgba(200, 120, 150, 0.25);
}

.rank-msg {
  min-height: 1.2em;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
}

@media (max-width: 380px) {
  .meta-row {
    grid-template-columns: 60px 1fr 60px;
  }

  .meta-slot canvas {
    width: 56px;
    height: 56px;
  }

  .mini-stat {
    min-width: 56px;
    padding: 5px 7px;
  }
}

@media (min-height: 780px) {
  .board-wrap {
    width: min(100%, calc(76dvh * 0.5), 440px);
  }
}
