:root {
  color-scheme: dark;
  font-family: Inter, ui-rounded, "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  background: #10051c;
  color: #fff;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #08030e;
}

body {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(89, 29, 91, .42), transparent 38%),
    #08030e;
}

button { font: inherit; }

#game-shell {
  position: relative;
  width: min(100vw, 60vh);
  height: min(100vh, 166.6667vw);
  width: min(100vw, 60svh);
  height: min(100svh, 166.6667vw);
  min-width: 0;
  min-height: 0;
  aspect-ratio: 9 / 15;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(circle at 50% 38%, #43124c 0%, #1f0b32 44%, #0c0415 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,.09), 0 24px 80px rgba(0,0,0,.62);
}

#game-shell::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 14% 0 20.8%;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(226,134,183,.105) 1px, transparent 1px),
    linear-gradient(90deg, rgba(226,134,183,.105) 1px, transparent 1px),
    linear-gradient(180deg, transparent 76%, rgba(255,82,153,.13));
  background-size: 52px 52px, 52px 52px, 100% 100%;
  border-bottom: 2px solid rgba(255,111,171,.44);
  box-shadow: 0 35px 70px rgba(19,2,24,.56);
}

#game-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.topbar {
  position: absolute;
  z-index: 4;
  top: max(11px, env(safe-area-inset-top));
  left: max(11px, env(safe-area-inset-left));
  right: max(11px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.brand { filter: drop-shadow(0 4px 12px rgba(0,0,0,.35)); }
.eyebrow { color: #f6aacb; font-weight: 900; font-size: 7px; letter-spacing: .18em; }
h1 { margin: 3px 0 0; font-size: 16px; line-height: .95; letter-spacing: -.045em; white-space: nowrap; }
h1 em { color: #ff4f99; font-style: normal; }

.meters { display: flex; gap: 3px; }
.meter-card {
  min-width: 49px;
  padding: 5px 5px 6px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(26,11,43,.88), rgba(15,5,27,.72));
  box-shadow: 0 12px 26px rgba(0,0,0,.24), inset 0 1px rgba(255,255,255,.09);
  text-align: right;
  backdrop-filter: blur(12px);
}
.meter-card span { display: block; color: #b9a6c6; font-size: 6px; font-weight: 900; letter-spacing: .12em; }
.meter-card strong { display: block; margin-top: 1px; font-size: 14px; font-variant-numeric: tabular-nums; }
.meter-card--score { min-width: 58px; }
.meter-card--score small {
  display: block;
  margin-top: 1px;
  color: #9f8bad;
  font-size: 6px;
  font-weight: 900;
  letter-spacing: .08em;
  white-space: nowrap;
}
.meter-card--score small b { color: #ffd3e4; font-size: 7px; }
.meter-card--break strong { color: #ff70aa; }
.meter-card--time strong { color: #ffe491; }

.mission {
  position: absolute;
  z-index: 3;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  color: #decfe8;
  background: rgba(18,6,31,.54);
  border: 1px solid rgba(255,255,255,.08);
  font-size: 10px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}
.mission-label { color: #ff76b0; font-size: 7px; font-weight: 900; letter-spacing: .14em; }

.physics-status {
  position: absolute;
  z-index: 4;
  top: 89px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border: 1px solid rgba(255,170,204,.18);
  border-radius: 999px;
  color: rgba(255,218,232,.72);
  background: rgba(15,4,27,.48);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: .1em;
  white-space: nowrap;
  pointer-events: none;
}
.physics-status.is-error { color: #ffe296; border-color: rgba(255,226,150,.45); }

.gesture-preview,
.weapon-effect {
  position: absolute;
  z-index: 8;
  height: 5px;
  border-radius: 999px;
  transform-origin: 0 50%;
  pointer-events: none;
}
.gesture-preview {
  opacity: .75;
  background: repeating-linear-gradient(90deg, #ffc0d9 0 15px, transparent 15px 23px);
  filter: drop-shadow(0 0 8px #ff4f99);
}
.gesture-preview[data-weapon="hammer"] {
  height: 10px;
  background: linear-gradient(90deg, rgba(255,229,153,.3), #ffe599);
  filter: drop-shadow(0 0 10px #ffc04d);
}
.gesture-preview[data-weapon="spear"] {
  height: 4px;
  background: #e7f9ff;
  filter: drop-shadow(0 0 9px #65d4ff);
}
.weapon-effect { animation: weapon-line .52s ease-out forwards; }
.weapon-effect { transform: rotate(var(--effect-angle, 0)); }
.weapon-effect--katana {
  height: 12px;
  background: #fff;
  box-shadow: 0 0 24px 7px rgba(255,75,153,.8);
}
.weapon-effect--spear {
  height: 7px;
  background: #eaffff;
  box-shadow: 0 0 19px 5px rgba(87,210,255,.72);
}
@keyframes weapon-line {
  from { opacity: 1; clip-path: inset(0 100% 0 0); }
  28% { clip-path: inset(0 0 0 0); }
  to { opacity: 0; transform: rotate(var(--effect-angle, 0)) scaleX(1.08); clip-path: inset(0 0 0 0); }
}

.impact-effect {
  position: absolute;
  z-index: 7;
  width: 80px;
  aspect-ratio: 1;
  border: 6px solid #ffe7a0;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(.2);
  box-shadow: 0 0 20px rgba(255,205,88,.6);
  pointer-events: none;
  animation: impact-ring .58s ease-out forwards;
}
.impact-effect--spear { width: 42px; border-width: 4px; border-color: #dff8ff; }
@keyframes impact-ring {
  to { opacity: 0; transform: translate(-50%, -50%) scale(2.4); }
}

.weapon-panel {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: max(31px, calc(env(safe-area-inset-bottom) + 12px));
  transform: translateX(-50%);
  display: flex;
  width: calc(100% - 16px);
  gap: 4px;
  padding: 5px;
  border-radius: 17px;
  background: rgba(14,5,25,.83);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 18px 46px rgba(0,0,0,.44), inset 0 1px rgba(255,255,255,.08);
  backdrop-filter: blur(16px);
}

.weapon {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 50px;
  flex: 1;
  padding: 6px 5px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #d9c9e4;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: transform .14s ease, background .14s ease, border-color .14s ease;
}
.weapon:hover { transform: translateY(-2px); background: rgba(255,255,255,.055); }
.weapon.is-active {
  color: #fff;
  background: linear-gradient(145deg, rgba(255,77,153,.26), rgba(129,67,207,.2));
  border-color: rgba(255,132,184,.54);
  box-shadow: inset 0 0 24px rgba(255,61,145,.12), 0 8px 20px rgba(0,0,0,.24);
}
.weapon-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #24102f;
  background: linear-gradient(145deg, #ffe7f0, #ff73ad);
  font-size: 17px;
  font-weight: 1000;
  box-shadow: inset 0 1px rgba(255,255,255,.8);
}
.weapon-copy b, .weapon-copy small { display: block; }
.weapon-copy b { font-size: 11px; white-space: nowrap; }
.weapon-copy small { display: none; }
.weapon-key {
  position: absolute;
  top: 3px;
  right: 5px;
  color: #8d769d;
  font-size: 7px;
  font-weight: 900;
}

.hint {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(9px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  color: rgba(255,255,255,.6);
  max-width: calc(100% - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

.callout {
  position: absolute;
  z-index: 6;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.85);
  color: #fff;
  font-size: clamp(25px, 8vw, 44px);
  font-weight: 1000;
  font-style: italic;
  letter-spacing: -.05em;
  text-shadow: 0 4px 0 #8a1750, 0 10px 26px rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
}
.callout.is-visible { animation: callout .72s cubic-bezier(.17,.84,.32,1); }
@keyframes callout {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.45) rotate(-5deg); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(1deg); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(.96); }
}

.gather-banner {
  position: absolute;
  z-index: 3;
  top: 17.5%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.9);
  color: #ffb8d5;
  padding: 5px 12px;
  border: 1px solid rgba(255, 134, 185, .32);
  border-radius: 999px;
  background: rgba(38, 8, 53, .7);
  font-size: clamp(9px, 2.8vw, 14px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: .12em;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 0 18px rgba(255,62,145,.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.gather-banner.is-visible { opacity: .72; transform: translate(-50%, -50%) scale(1); }

.install-chip {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: max(98px, calc(env(safe-area-inset-bottom) + 78px));
  transform: translateX(-50%);
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid rgba(255,174,207,.52);
  border-radius: 999px;
  color: #fff;
  background: rgba(57,16,69,.88);
  box-shadow: 0 8px 24px rgba(0,0,0,.35), inset 0 1px rgba(255,255,255,.13);
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.install-chip[hidden] { display: none; }

.result {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8,2,14,.72);
  backdrop-filter: blur(12px);
}
.result.is-hidden { display: none; }
.result-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 28px;
  background: linear-gradient(155deg, #35113f, #160822);
  box-shadow: 0 30px 90px rgba(0,0,0,.55), inset 0 1px rgba(255,255,255,.1);
  text-align: center;
}
.result-card h2 { margin: 8px 0 4px; font-size: 25px; }
.result-card > strong { display: block; color: #ff76b0; font-size: 64px; font-variant-numeric: tabular-nums; }
.new-best {
  display: inline-block;
  margin-top: 2px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #38111e;
  background: #ffe491;
  font-size: 9px;
  font-weight: 1000;
  letter-spacing: .12em;
}
.new-best[hidden] { display: none; }
.result-best { margin: 10px 0 0; color: #bca9c8; font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.result-best strong { color: #fff; font-size: 14px; font-variant-numeric: tabular-nums; }
.result-card button {
  margin-top: 18px;
  padding: 13px 24px;
  border: 0;
  border-radius: 999px;
  color: #2c0d27;
  background: linear-gradient(90deg, #ff70aa, #ffd0e1);
  font-weight: 900;
  cursor: pointer;
}

.gpu-error {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 25px;
  background: rgba(8,2,14,.86);
  backdrop-filter: blur(12px);
}
.gpu-error[hidden] { display: none; }
.gpu-error-card {
  padding: 28px 24px;
  border: 1px solid rgba(255,226,150,.28);
  border-radius: 24px;
  background: linear-gradient(155deg, #35113f, #160822);
  text-align: center;
}
.gpu-error-card h2 { margin: 9px 0; font-size: 20px; }
.gpu-error-card p { margin: 0; color: #d9c9e4; font-size: 12px; line-height: 1.8; }

@media (max-width: 340px), (max-height: 540px) {
  .brand .eyebrow, .mission, .physics-status, .weapon-key { display: none; }
  .weapon-panel { bottom: max(27px, calc(env(safe-area-inset-bottom) + 9px)); }
}
