:root {
  color-scheme: dark;
  --bg: #090d1d;
  --bg-2: #121936;
  --panel: rgba(14, 21, 48, 0.84);
  --panel-strong: rgba(18, 28, 63, 0.96);
  --line: rgba(164, 184, 255, 0.18);
  --text: #f5f7ff;
  --muted: #aeb8de;
  --accent: #69e4ff;
  --accent-2: #7d7cff;
  --accent-3: #ffcc66;
  --danger: #ff6f8f;
  --success: #8effb6;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.35);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --font: "Pretendard", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(105, 228, 255, 0.2), transparent 28%),
    radial-gradient(circle at 20% 20%, rgba(125, 124, 255, 0.22), transparent 24%),
    radial-gradient(circle at 80% 18%, rgba(255, 204, 102, 0.14), transparent 20%),
    linear-gradient(180deg, #060912 0%, #0b1124 48%, #070a16 100%);
}

body.state-pressure-mid .status-pill--timer,
body.state-pressure-high .status-pill--timer {
  animation: timerPulse 0.9s ease-in-out infinite;
}

body.state-pressure-high .sequence-card {
  box-shadow: 0 0 0 1px rgba(255, 111, 143, 0.16), 0 26px 90px rgba(255, 111, 143, 0.18);
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.shell {
  display: grid;
  gap: 22px;
}

.hero,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(17, 24, 53, 0.94), rgba(10, 15, 34, 0.92));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero {
  padding: 28px 30px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -8% -30% auto;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(105, 228, 255, 0.18), transparent 70%);
  pointer-events: none;
}

.hero__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.hero__back,
.ghost-button {
  color: var(--text);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
}

.hero__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
}

.hero__badge,
.eyebrow,
.pressure-indicator,
.status-pill__label,
.best-box__label {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
}

.hero__badge {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(105, 228, 255, 0.12);
  color: var(--accent);
}

.hero__title {
  margin: 22px 0 10px;
  font-size: clamp(42px, 6vw, 72px);
  line-height: 0.95;
}

.hero__subtitle {
  margin: 0;
  max-width: 760px;
  color: var(--muted);
  font-size: clamp(16px, 2.4vw, 20px);
  line-height: 1.6;
}

.screen {
  display: none;
}

.screen.is-active {
  display: grid;
  gap: 22px;
}

.panel {
  padding: 24px;
}

.panel--hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.8fr);
  gap: 22px;
  align-items: stretch;
}

.panel__title {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
}

.panel__title--small {
  font-size: clamp(22px, 3vw, 28px);
}

.panel__text,
.compact-panel p,
.guide-grid p,
.feedback-message,
.attempt-summary,
.control-help p,
.result-player {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.player-field {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.player-field span {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.player-field input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 16px 18px;
  font: inherit;
}

.player-field input:focus {
  outline: 2px solid rgba(105, 228, 255, 0.35);
  outline-offset: 2px;
}

.start-actions,
.result-actions,
.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.start-actions {
  margin-top: 24px;
}

.primary-button,
.ghost-button {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.primary-button {
  border: none;
  color: #06111f;
  background: linear-gradient(135deg, var(--accent), #8df7d7);
  box-shadow: 0 12px 34px rgba(105, 228, 255, 0.28);
}

.ghost-button:hover,
.hero__back:hover,
.primary-button:hover {
  transform: translateY(-2px);
}

.best-box {
  min-width: 140px;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 6px;
}

.best-box__value {
  font-size: 28px;
}

.hero-preview {
  position: relative;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(125, 124, 255, 0.18), rgba(105, 228, 255, 0.08)),
    rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 24px;
  display: grid;
  align-content: center;
  gap: 20px;
  overflow: hidden;
}

.hero-preview__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.hero-preview__arrow {
  display: grid;
  place-items: center;
  min-height: 88px;
  border-radius: 20px;
  font-size: 38px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-preview__arrow--active {
  color: #08111d;
  background: linear-gradient(135deg, #ffe799, var(--accent-3));
  transform: scale(1.04);
  box-shadow: 0 16px 32px rgba(255, 204, 102, 0.28);
}

.hero-preview__meter {
  display: grid;
  gap: 10px;
}

.hero-preview__meter span {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(125, 124, 255, 0.2), rgba(105, 228, 255, 0.8));
}

.hero-preview__meter span:nth-child(2) {
  width: 78%;
}

.hero-preview__meter span:nth-child(3) {
  width: 56%;
}

.info-grid,
.guide-grid,
.result-grid {
  display: grid;
  gap: 18px;
}

.info-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-panel h3,
.guide-grid h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.rule-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.game-panel {
  display: grid;
  gap: 18px;
}

.status-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.status-pill {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 8px;
}

.status-pill__value {
  font-size: clamp(22px, 4vw, 34px);
}

.status-pill--timer {
  position: relative;
  overflow: hidden;
}

.status-pill--timer::after {
  content: "";
  position: absolute;
  inset: auto -20% -60% auto;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(105, 228, 255, 0.18), transparent 70%);
}

body.state-pressure-mid .status-pill--timer {
  border-color: rgba(255, 204, 102, 0.32);
}

body.state-pressure-high .status-pill--timer {
  border-color: rgba(255, 111, 143, 0.45);
  color: #fff4f7;
}

.sequence-card {
  border-radius: 24px;
  padding: 22px;
  background: linear-gradient(180deg, rgba(19, 28, 63, 0.96), rgba(9, 16, 37, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.sequence-card.is-success {
  border-color: rgba(142, 255, 182, 0.36);
  box-shadow: 0 0 0 1px rgba(142, 255, 182, 0.12), 0 18px 46px rgba(142, 255, 182, 0.14);
}

.sequence-card.is-error {
  border-color: rgba(255, 111, 143, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 111, 143, 0.12), 0 18px 46px rgba(255, 111, 143, 0.16);
  animation: shake 0.22s ease;
}

.sequence-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 8px;
  align-content: center;
  background: rgba(5, 10, 24, 0.78);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 2;
}

.countdown-overlay.is-visible {
  opacity: 1;
}

.countdown-overlay__label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.countdown-overlay__value {
  font-size: clamp(64px, 11vw, 112px);
  line-height: 1;
  color: #fff5d3;
  text-shadow: 0 0 24px rgba(255, 204, 102, 0.32);
}

.pressure-indicator {
  min-width: 96px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(105, 228, 255, 0.08);
}

.pressure-indicator.is-mid {
  color: var(--accent-3);
  background: rgba(255, 204, 102, 0.1);
}

.pressure-indicator.is-high {
  color: #ffd4df;
  background: rgba(255, 111, 143, 0.12);
}

.sequence {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 12px;
}

.sequence-slot {
  min-height: 98px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.sequence-slot::after {
  content: attr(data-index);
  position: absolute;
  top: 10px;
  left: 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.34);
}

.sequence-slot__arrow {
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 800;
}

.sequence-slot--current {
  background: linear-gradient(180deg, rgba(255, 204, 102, 0.2), rgba(255, 204, 102, 0.08));
  border-color: rgba(255, 204, 102, 0.5);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 16px 34px rgba(255, 204, 102, 0.14);
}

.sequence-slot--incoming {
  animation: popIn 0.22s ease;
}

.sequence-slot--current .sequence-slot__arrow {
  color: var(--accent-3);
}

.feedback-row,
.control-help {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.feedback-message {
  font-weight: 600;
}

.feedback-message.is-success {
  color: var(--success);
}

.feedback-message.is-error {
  color: #ffbdcb;
}

.control-help {
  font-size: 14px;
}

.result-panel {
  display: grid;
  gap: 20px;
}

.result-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.result-card {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 10px;
}

.result-card span {
  color: var(--muted);
  font-size: 14px;
}

.result-card strong {
  font-size: clamp(24px, 4vw, 34px);
}

.copy-feedback {
  min-height: 22px;
  color: var(--accent);
  font-size: 14px;
}

.guide-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(105, 228, 255, 0.65);
  outline-offset: 2px;
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

@keyframes timerPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: none;
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 0 4px rgba(255, 111, 143, 0.08);
  }
}

@media (max-width: 960px) {
  .panel--hero,
  .info-grid,
  .guide-grid {
    grid-template-columns: 1fr;
  }

  .status-bar,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sequence {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 20px, 1120px);
    padding-top: 18px;
  }

  .hero,
  .panel {
    padding: 18px;
  }

  .hero__top,
  .sequence-card__header,
  .feedback-row,
  .control-help {
    flex-direction: column;
    align-items: stretch;
  }

  .status-bar,
  .result-grid,
  .sequence {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sequence-slot {
    min-height: 82px;
  }
}
