:root {
  color-scheme: dark;
  --ink: #f8fafc;
  --muted: #a7b0c0;
  --panel: rgba(12, 16, 24, 0);
  --line: rgba(255, 255, 255, 0.16);
  --accent: #53d2ff;
  --accent-strong: #ffcf4a;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 18%, rgba(83, 210, 255, 0.24), transparent 28rem),
    radial-gradient(circle at 82% 78%, rgba(255, 207, 74, 0.18), transparent 24rem),
    #090d14;
}

button {
  font: inherit;
}

.game-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
}

.game-stage {
  position: relative;
  width: min(100vw - 32px, 540px);
  aspect-ratio: 540 / 760;
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #080c13;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
  touch-action: none;
  user-select: none;
}

.emoji-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.emoji-sprite {
  position: absolute;
  left: 0;
  top: 0;
  width: 1em;
  height: 1em;
  display: grid;
  place-items: center;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", emoji, sans-serif;
  font-size: var(--emoji-size);
  line-height: 1;
  transform: translate(-50%, -50%) scale(var(--emoji-scale, 1));
  filter: drop-shadow(0 0 10px var(--emoji-glow, rgba(255, 255, 255, 0.42)));
  user-select: none;
}

.emoji-sprite.is-player {
  z-index: 5;
}

.emoji-sprite.is-boss {
  z-index: 3;
}

.emoji-sprite.is-medal {
  z-index: 4;
  filter:
    drop-shadow(0 0 8px var(--emoji-glow, rgba(255, 255, 255, 0.42)))
    drop-shadow(0 0 18px var(--emoji-glow, rgba(255, 255, 255, 0.42)));
}

.emoji-sprite.is-recovery {
  z-index: 6;
  filter:
    drop-shadow(0 0 8px #ffffff)
    drop-shadow(0 0 20px var(--emoji-glow, rgba(83, 210, 255, 1)))
    drop-shadow(0 0 36px rgba(83, 210, 255, 0.88));
}

.emoji-sprite.is-ending {
  filter: drop-shadow(0 0 18px rgba(255, 207, 74, 0.78));
}

.emoji-sprite.is-ending-back {
  opacity: 0.36;
  z-index: 0;
  filter: drop-shadow(0 0 32px rgba(83, 210, 255, 0.72));
}

.ending-title {
  position: absolute;
  left: 50%;
  top: 39%;
  transform: translate(-50%, -50%) scale(var(--title-scale, 1));
  z-index: 2;
  width: min(92%, 520px);
  color: #ffffff;
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: clamp(30px, 8vw, 43px);
  font-weight: 900;
  line-height: 1.02;
  text-align: center;
  text-shadow:
    0 0 24px rgba(83, 210, 255, 0.92),
    2px 2px 0 #53d2ff;
  pointer-events: none;
}

.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 2;
}

.control-hint {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 2;
  color: rgba(248, 250, 252, 0.78);
  font-size: clamp(11px, 2.5vw, 13px);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.82);
  pointer-events: none;
}

.hint-mobile {
  display: none;
}

@media (pointer: coarse) {
  .hint-pc {
    display: none;
  }

  .hint-mobile {
    display: inline;
  }
}

.stage-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 3px;
  height: 0%;
  z-index: 2;
  background: rgba(83, 210, 255, 0.42);
  box-shadow: 0 0 10px rgba(83, 210, 255, 0.32);
  pointer-events: none;
}

.hud > div {
  position: relative;
  min-width: 88px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
  backdrop-filter: none;
}

.hud-label {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
  letter-spacing: 0;
  color: var(--muted);
}

.hud strong {
  display: block;
  font-size: 18px;
  line-height: 1;
}

.rainbow-stock {
  display: grid;
  grid-template-columns: repeat(3, 22px);
  gap: 4px;
  min-height: 22px;
  margin-top: 5px;
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0;
  filter: drop-shadow(0 0 7px rgba(255, 207, 74, 0.52));
}

.rainbow-slot {
  position: relative;
  width: 22px;
  height: 22px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 10px rgba(83, 210, 255, 0.32);
}

.rainbow-slot-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 0%;
  background: #53d2ff;
  box-shadow: 0 0 10px rgba(83, 210, 255, 0.72);
}

.rainbow-slot::after {
  content: "\1F308";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
  opacity: 0.42;
}

.rainbow-slot.is-filled::after {
  opacity: 1;
}

.rainbow-slot.is-empty::after {
  opacity: 0.18;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
  background: rgba(7, 10, 17, 0.62);
  backdrop-filter: blur(6px);
  z-index: 3;
}

.start-overlay.is-restart-only {
  background: transparent;
  backdrop-filter: none;
  place-content: end center;
  padding-bottom: 120px;
  pointer-events: none;
}

.start-overlay.is-hidden {
  display: none;
}

.start-overlay h1 {
  margin: 0;
  font-size: clamp(34px, 9vw, 64px);
  line-height: 0.95;
}

.start-overlay p {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.character-select {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: min(100%, 342px);
  margin: 0 auto;
}

.start-overlay .character-card {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  padding: 6px 4px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: #f8fafc;
  background: #2f3338;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.start-overlay .character-card.is-selected {
  border-color: #fff1a6;
  color: #21113e;
  background: #ffcf4a;
  box-shadow: 0 0 18px rgba(255, 207, 74, 0.32);
}

.start-overlay .character-card.is-locked {
  opacity: 0.42;
  color: #f8fafc;
  background: #2f3338;
}

.character-emoji {
  font-size: clamp(28px, 7vw, 40px);
  line-height: 1;
}

.character-name {
  max-width: 100%;
  font-size: clamp(10px, 2.6vw, 12px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.character-requirement {
  max-width: 100%;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.1;
  color: #ffe27a;
  text-align: center;
}

.character-info {
  min-height: 34px;
  width: min(100%, 342px);
  margin: 2px auto 0;
  display: grid;
  place-items: center;
  color: #ffe27a;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
}

.character-info:not(.is-visible) {
  color: transparent;
}

.start-overlay.is-restart-only h1,
.start-overlay.is-restart-only p {
  display: none;
}

.start-overlay.is-restart-only .character-select {
  display: none;
}

.start-overlay button {
  justify-self: center;
  margin-top: 4px;
  min-width: 124px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #071018;
  background: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
}

.start-overlay.is-restart-only button {
  pointer-events: auto;
}

.start-overlay button:hover {
  filter: brightness(1.08);
}

.start-overlay .admin-test-button {
  min-width: 190px;
  min-height: 34px;
  margin-top: -4px;
  color: #f8fafc;
  background: #3f4654;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 12px;
}

.start-overlay .admin-test-button[hidden] {
  display: none;
}

.name-panel {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(7, 10, 17, 0.72);
  backdrop-filter: blur(7px);
  z-index: 4;
}

.name-panel.active {
  display: grid;
}

.name-box {
  width: min(100%, 340px);
  padding: 20px 16px;
  border: 1px solid rgba(83, 210, 255, 0.35);
  border-radius: 8px;
  background: rgba(8, 12, 19, 0.92);
  text-align: center;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.46);
}

.name-box h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.name-box p {
  margin: 0 0 14px;
  color: var(--accent-strong);
  font-size: 22px;
  font-weight: 900;
}

.name-box input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
  font: inherit;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}

.name-box button {
  width: 100%;
  min-height: 46px;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  color: #071018;
  background: var(--accent-strong);
  font-weight: 900;
}

@media (max-width: 520px) {
  .game-shell {
    padding: 0;
  }

  .game-stage {
    width: 100vw;
    max-height: 100vh;
    border: 0;
    border-radius: 0;
  }
}
