:root {
  color-scheme: light;
  font-family:
    Inter, Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", system-ui,
    -apple-system, sans-serif;
  color: #143d3e;
  background: #e8eceb;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  container-type: inline-size;
  width: 100%;
  min-width: 320px;
  height: 100%;
  min-height: 520px;
  isolation: isolate;
  overflow: hidden;
  background: #fbfbfb;
}

#marble-canvas {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#marble-canvas.is-dragging {
  cursor: grabbing;
}

.target-ring {
  display: none;
}

.aim-layer {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.aim-layer.is-visible {
  opacity: 1;
}

.aim-layer line {
  stroke: rgba(17, 78, 76, 0.65);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 5 7;
}

.aim-layer circle {
  fill: rgba(255, 255, 255, 0.92);
  stroke: rgba(17, 78, 76, 0.72);
  stroke-width: 1.5;
}

.power-meter {
  position: absolute;
  z-index: 4;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  left: 50%;
  display: grid;
  grid-template-columns: auto minmax(140px, 210px) 28px;
  align-items: center;
  gap: 10px;
  width: min(88vw, 310px);
  min-height: 42px;
  padding: 7px 10px 7px 13px;
  border: 1px solid rgba(20, 74, 72, 0.14);
  border-radius: 14px;
  color: #174746;
  background: rgba(248, 251, 250, 0.82);
  box-shadow:
    0 14px 42px rgba(28, 68, 67, 0.12),
    inset 0 1px rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px) saturate(118%);
  transform: translateX(-50%);
  pointer-events: none;
}

.power-meter > span,
.power-meter > strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.power-meter > span {
  color: rgba(20, 61, 62, 0.58);
}

.power-meter > strong {
  text-align: right;
}

.power-track {
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(20, 74, 72, 0.11);
  box-shadow: inset 0 1px 2px rgba(17, 67, 65, 0.08);
}

.power-track i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4aaea5 0%, #39a995 58%, #efa45a 100%);
  box-shadow: 0 0 10px rgba(51, 158, 145, 0.28);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 45ms linear;
}

.topbar {
  position: absolute;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top));
  right: clamp(14px, 3vw, 34px);
  left: clamp(14px, 3vw, 34px);
  display: grid;
  grid-template-columns: minmax(94px, 1fr) auto minmax(94px, 1fr);
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 9px;
  min-height: 38px;
  color: #123f3e;
  text-decoration: none;
}

.brand > span {
  width: 9px;
  height: 9px;
  border: 1px solid rgba(17, 78, 76, 0.45);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #fff 0 12%, transparent 14%),
    linear-gradient(145deg, rgba(71, 176, 173, 0.88), rgba(13, 89, 98, 0.65));
  box-shadow: 0 2px 8px rgba(21, 86, 84, 0.20);
}

.brand strong {
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.045em;
}

.mode-switcher,
.top-actions,
.game-hud,
.background-switcher,
.control-row {
  border: 1px solid rgba(20, 74, 72, 0.12);
  background: rgba(247, 250, 249, 0.76);
  box-shadow:
    0 13px 42px rgba(28, 68, 67, 0.09),
    inset 0 1px rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px) saturate(115%);
}

.mode-switcher {
  display: flex;
  justify-self: center;
  gap: 3px;
  padding: 4px;
  border-radius: 12px;
}

button,
.discord-link {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(22, 73, 72, 0.12);
  border-radius: 9px;
  color: #174746;
  background: rgba(255, 255, 255, 0.54);
  box-shadow: 0 2px 8px rgba(28, 68, 67, 0.04);
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

button:hover,
.discord-link:hover {
  border-color: rgba(22, 73, 72, 0.25);
  background: rgba(255, 255, 255, 0.88);
  transform: translateY(-1px);
}

button:active,
.discord-link:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid #278983;
  outline-offset: 2px;
}

.mode-switcher button {
  min-width: 64px;
  min-height: 30px;
  padding: 0 12px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  font-size: 10px;
}

.mode-switcher button[aria-pressed="true"],
.background-switcher button[aria-pressed="true"] {
  border-color: rgba(28, 113, 108, 0.24);
  color: #0f514f;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 8px rgba(28, 68, 67, 0.10);
}

.top-actions {
  display: flex;
  justify-self: end;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
}

.menu-toggle svg {
  width: 15px;
  height: 15px;
  margin-right: 5px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}

.menu-toggle .menu-expand {
  display: none;
}

.menu-toggle[aria-pressed="true"] .menu-collapse {
  display: none;
}

.menu-toggle[aria-pressed="true"] .menu-expand {
  display: initial;
}

.stage.is-ui-hidden .brand,
.stage.is-ui-hidden .mode-switcher,
.stage.is-ui-hidden .game-hud,
.stage.is-ui-hidden .controls,
.stage.is-ui-hidden .performance,
.stage.is-ui-hidden .visual-test-toggle {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.stage.is-ui-hidden .top-actions {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.stage.is-ui-hidden .top-actions > :not(#menu-toggle) {
  display: none;
}

.discord-link {
  display: inline-grid;
  place-items: center;
  align-items: center;
  width: 32px;
  min-height: 30px;
  padding: 0;
  text-decoration: none;
}

.help-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  min-height: 30px;
  padding: 0;
  color: rgba(23, 71, 70, 0.78);
  font-size: 15px;
  font-weight: 850;
}

.discord-link svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  opacity: 0.78;
}

.share-icon {
  width: 13px;
  height: 13px;
  margin-right: 5px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -2px;
}

.compact-button {
  min-height: 30px;
  padding: 0 10px;
}

.sound-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 14px;
  margin-right: 5px;
  color: rgba(23, 71, 70, 0.58);
  font-size: 14px;
  vertical-align: -1px;
}

#sound-toggle[aria-pressed="false"] .sound-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 1px;
  border-radius: 99px;
  background: rgba(23, 71, 70, 0.34);
  transform: translate(-50%, -50%) rotate(48deg);
}

#sound-toggle[aria-pressed="true"] .sound-icon {
  color: #258b78;
  text-shadow: 0 0 8px rgba(37, 139, 120, 0.28);
}

.game-hud {
  position: absolute;
  z-index: 4;
  top: max(70px, calc(env(safe-area-inset-top) + 56px));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 7px;
  border-radius: 15px;
  transform: translateX(-50%);
}

.game-stat {
  display: grid;
  gap: 2px;
  min-width: 64px;
  padding: 0 8px;
  text-align: center;
}

.game-stat span {
  color: rgba(20, 61, 62, 0.56);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.game-stat strong {
  color: #123f3e;
  font-size: 16px;
  line-height: 1.1;
}

.game-hud > i {
  width: 1px;
  height: 28px;
  background: rgba(20, 61, 62, 0.13);
}

.game-hud button {
  min-height: 38px;
  white-space: nowrap;
}

.controls {
  position: absolute;
  z-index: 4;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  justify-items: end;
  gap: 8px;
}

.background-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border-radius: 12px;
}

.background-switcher > span {
  padding: 0 7px;
  color: rgba(20, 61, 62, 0.58);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.background-switcher button {
  min-width: 46px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 10px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px;
  border-radius: 15px;
}

.button-icon {
  display: inline-block;
  margin-right: 7px;
  vertical-align: -1px;
}

.pause-icon {
  width: 8px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-left: 2px solid currentColor;
}

button[aria-pressed="true"] .pause-icon {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-right: 0;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}

.scatter-icon {
  color: #2b7773;
  font-size: 13px;
}

.tilt-icon {
  width: 14px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  color: #2b7773;
  transform: rotate(-14deg);
}

#tilt-toggle[aria-pressed="true"] .tilt-icon {
  color: #258b78;
  box-shadow: 0 0 8px rgba(37, 139, 120, 0.28);
}

.count-control {
  display: grid;
  grid-template-columns: auto 86px 24px;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 9px 0 11px;
  color: rgba(20, 61, 62, 0.68);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

input[type="range"] {
  width: 86px;
  height: 3px;
  margin: 0;
  border-radius: 10px;
  appearance: none;
  background: rgba(22, 73, 72, 0.18);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  appearance: none;
  background: #277f7b;
  box-shadow: 0 1px 5px rgba(18, 68, 66, 0.25);
}

output {
  color: #174746;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  text-align: right;
}

.result-panel {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  width: min(86vw, 340px);
  padding: 24px;
  border: 1px solid rgba(20, 74, 72, 0.16);
  border-radius: 20px;
  color: #123f3e;
  background: rgba(250, 252, 251, 0.91);
  box-shadow:
    0 28px 90px rgba(26, 64, 63, 0.18),
    inset 0 1px rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(22px) saturate(120%);
  transform: translate(-50%, -50%);
  text-align: center;
}

.result-panel h1 {
  margin: 0;
  font-family: inherit;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.help-backdrop {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(13, 43, 42, 0.24);
  backdrop-filter: blur(5px);
}

.help-dialog {
  position: relative;
  width: min(92vw, 390px);
  max-height: calc(100% - 12px);
  padding: 27px 24px 22px;
  overflow: auto;
  border: 1px solid rgba(17, 17, 17, 0.28);
  border-radius: 22px;
  color: #111;
  background: #fff;
  box-shadow:
    0 30px 100px rgba(16, 51, 50, 0.26),
    inset 0 1px rgba(255, 255, 255, 0.96);
  outline: none;
}

.help-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  min-height: 32px;
  padding: 0 0 2px;
  border: 2px solid #111;
  border-radius: 7px;
  color: #111;
  background: #fff;
  box-shadow: 3px 3px 0 #111;
  font-size: 21px;
  font-weight: 650;
}

.help-eyebrow {
  margin: 0 0 6px;
  color: #111;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.help-dialog h1 {
  margin: 0 0 18px;
  font-size: 25px;
  font-weight: 850;
  letter-spacing: -0.045em;
}

.help-content {
  display: grid;
  gap: 9px;
}

.help-mode {
  padding: 15px 16px;
  border: 1.5px solid #1d1d1d;
  border-radius: 10px;
  background: #fff;
}

.help-mode h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 7px;
  font-size: 14px;
  font-weight: 850;
  letter-spacing: -0.025em;
}

.help-mode h2 span {
  color: #111;
  font-size: 13px;
}

.help-mode p {
  margin: 0;
  color: #242424;
  font-size: 11px;
  font-weight: 580;
  line-height: 1.65;
  word-break: keep-all;
}

.help-mode p + p {
  margin-top: 5px;
}

.help-mode .help-note {
  color: #5a5a5a;
  font-size: 10px;
}

.help-confirm {
  width: 100%;
  margin-top: 13px;
  border: 2px solid #111;
  border-radius: 7px;
  color: #111;
  background: #fff;
  box-shadow: 4px 4px 0 #111;
  font-weight: 850;
}

.help-close:hover,
.help-confirm:hover {
  border-color: #111;
  background: #fff;
  box-shadow: 5px 5px 0 #111;
  transform: translate(-1px, -1px);
}

.help-close:active,
.help-confirm:active {
  box-shadow: 1px 1px 0 #111;
  transform: translate(2px, 2px);
}

.result-stars {
  margin: 15px 0 5px;
  color: #2a817d;
  font-size: 28px;
  letter-spacing: 0.12em;
}

.result-panel > strong {
  display: block;
  margin-bottom: 19px;
  font-size: 18px;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.result-actions button {
  padding: 0 9px;
}

.result-continue {
  grid-column: 1 / -1;
  border-color: rgba(28, 113, 108, 0.30);
  color: #0f514f;
  background: rgba(235, 250, 247, 0.96);
  box-shadow: 0 4px 15px rgba(28, 113, 108, 0.12);
}

.toast {
  position: absolute;
  z-index: 10;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 12px));
  left: 50%;
  padding: 10px 14px;
  border: 1px solid rgba(20, 74, 72, 0.14);
  border-radius: 99px;
  color: #123f3e;
  background: rgba(250, 252, 251, 0.94);
  box-shadow: 0 12px 36px rgba(26, 64, 63, 0.14);
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}



.performance {
  position: absolute;
  z-index: 6;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid rgba(20, 74, 72, 0.14);
  border-radius: 99px;
  background: rgba(250, 252, 251, 0.84);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8px;
  font-weight: 700;
}

.performance .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #33a87d;
}

.performance i {
  width: 1px;
  height: 10px;
  background: rgba(20, 61, 62, 0.16);
}

.error {
  position: absolute;
  z-index: 20;
  inset: 50% auto auto 50%;
  width: min(88vw, 420px);
  padding: 18px 22px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(90, 44, 32, 0.18);
  border-radius: 12px;
  color: #613d35;
  background: rgba(255, 248, 242, 0.94);
  text-align: center;
  font-size: 13px;
}

html[data-view="mobile"] body {
  display: grid;
  place-items: center;
  padding: 12px;
  background: #dfe5e3;
}

html[data-view="mobile"] .stage {
  width: 390px;
  min-width: 0;
  max-width: calc(100vw - 24px);
  height: min(844px, calc(100vh - 24px));
  min-height: min(520px, calc(100vh - 24px));
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(25, 56, 55, 0.18);
}

@container (max-width: 720px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 6px;
  }

  .brand strong {
    font-size: 16px;
  }

  .mode-switcher {
    justify-self: center;
  }

  .mode-switcher button {
    min-width: 54px;
    padding: 0 8px;
  }

  .discord-link {
    width: 32px;
    padding: 0;
  }

  .help-button {
    flex: 0 0 32px;
  }

  .compact-button {
    width: 32px;
    padding: 0;
  }

  .compact-button .button-label {
    display: none;
  }

  .compact-button .sound-icon {
    margin-right: 0;
  }

  .compact-button.menu-toggle svg {
    margin-right: 0;
  }

  .power-meter {
    grid-template-columns: auto minmax(90px, 1fr) 25px;
    width: min(82vw, 290px);
  }

  .game-hud {
    top: max(64px, calc(env(safe-area-inset-top) + 51px));
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 6px;
    width: min(94vw, 390px);
    padding: 6px;
  }

  .game-hud button {
    min-height: 34px;
    padding: 0 8px;
    font-size: 10px;
  }

  #restart-game {
    grid-column: 1 / 3;
  }

  #share-result {
    grid-column: 3;
  }

  .controls {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    justify-items: stretch;
  }

  .background-switcher {
    justify-self: end;
  }

  .control-row {
    justify-content: center;
  }

  .control-row button {
    width: 42px;
    padding: 0;
  }

  .control-row .button-label {
    display: none;
  }

  .control-row .button-icon {
    margin-right: 0;
  }

  .count-control {
    grid-template-columns: auto minmax(50px, 1fr) 21px;
    flex: 1;
    padding-right: 5px;
  }

  input[type="range"] {
    width: 100%;
  }
}

@container (max-width: 420px) {
  .brand strong {
    font-size: 0;
  }

  .brand > span {
    width: 13px;
    height: 13px;
  }
}

@container (max-width: 380px) {

  .game-hud {
    width: calc(100% - 20px);
  }

  .result-panel {
    padding: 20px 17px;
  }

  .help-dialog {
    padding: 24px 17px 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
