:root {
  --ink: #26323a;
  --muted: #69767d;
  --kokai-blue: #145c77;
  --kokai-teal: #13a5a6;
  --sun: #ffd46b;
  --sand: #f3d394;
  --sand-deep: #d9a95d;
  --foam: #f4fbf8;
  --paper: #fff7df;
  --danger: #df6b46;
  --success: #118b6f;
  --shadow: rgba(48, 40, 29, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 221, 128, 0.75), transparent 18rem),
    linear-gradient(180deg, #b9e5ef 0%, #d8f3f3 38%, #f7dfaa 39%, #f1c87e 100%);
  overflow: hidden;
}

button {
  font: inherit;
}

.game-shell {
  width: 100vw;
  height: 100svh;
  margin: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 18px;
  background: rgba(255, 247, 223, 0.9);
  box-shadow: 0 5px 14px rgba(20, 92, 119, 0.12);
  z-index: 2;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
}

.kokai-logo {
  width: 132px;
  max-height: 52px;
  object-fit: contain;
}

.eyebrow,
.label,
.stamp {
  margin: 0;
  color: var(--kokai-blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-size: clamp(1.05rem, 2vw, 1.7rem);
  line-height: 1.05;
}

.scoreboard {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.status-card {
  min-width: 94px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(20, 92, 119, 0.16);
  border-radius: 15px 10px 16px 12px;
  box-shadow: 2px 3px 0 rgba(20, 92, 119, 0.08);
}

.status-card strong {
  display: block;
  margin-top: 2px;
  font-size: 1.22rem;
}

.proximity-card {
  width: 174px;
}

.meter {
  height: 13px;
  margin: 5px 0 3px;
  overflow: hidden;
  border: 0;
  border-radius: 48% 52% 46% 54% / 58% 45% 55% 42%;
  background: rgba(20, 92, 119, 0.12);
  box-shadow: inset 0 1px 3px rgba(20, 92, 119, 0.18);
  transform: rotate(-0.6deg);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--kokai-teal), var(--sun), var(--danger));
  border-radius: 56% 44% 52% 48% / 46% 55% 45% 54%;
  transition: width 120ms ease-out;
}

.game-area {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--sand);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(20, 92, 119, 0.18);
  backdrop-filter: blur(2px);
}

.overlay.is-visible {
  display: grid;
}

.paper-panel {
  width: min(460px, 100%);
  padding: 24px;
  text-align: center;
  background:
    linear-gradient(105deg, transparent 0 48%, rgba(255, 212, 107, 0.22) 49% 52%, transparent 53%),
    var(--paper);
  border: 0;
  border-radius: 24px 17px 28px 19px;
  box-shadow: 5px 7px 20px rgba(38, 50, 58, 0.18);
  transform: rotate(0.5deg);
}

.paper-panel h2 {
  margin: 8px 0 10px;
  font-size: clamp(1.5rem, 4vw, 2.35rem);
  line-height: 1.02;
}

.paper-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.primary-button,
.icon-button {
  border: 0;
  color: white;
  background: var(--kokai-blue);
  border-radius: 15px 10px 17px 11px;
  box-shadow: 3px 4px 0 rgba(20, 92, 119, 0.18);
  cursor: pointer;
}

.primary-button {
  margin-top: 10px;
  padding: 11px 22px;
  font-weight: 900;
}

.primary-button:hover,
.icon-button:hover {
  background: #0f7287;
  transform: translateY(-1px) rotate(-0.4deg);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  background: rgba(255, 247, 223, 0.9);
  box-shadow: 0 -5px 14px rgba(20, 92, 119, 0.1);
  z-index: 2;
}

.controls p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.icon-button {
  min-width: 82px;
  padding: 8px 12px;
  font-weight: 900;
}

.icon-button span {
  display: inline-block;
  margin-right: 5px;
  transform: rotate(-18deg);
}

.tiny-mark {
  color: var(--kokai-blue);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .game-shell {
    width: 100vw;
    min-height: 0;
    height: 100svh;
    margin: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .topbar,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 7px;
    padding: 7px 10px;
  }

  .controls {
    gap: 6px;
    padding: 7px 10px;
  }

  .brand-lockup {
    min-width: 0;
  }

  .scoreboard {
    justify-content: stretch;
  }

  .status-card {
    flex: 1 1 92px;
  }

  .proximity-card {
    flex-basis: 100%;
    width: auto;
  }

  .controls {
    text-align: center;
  }

  .kokai-logo {
    width: 105px;
    max-height: 40px;
  }

  .controls p {
    display: none;
  }
}
