:root {
  color-scheme: light;
  --ink: #102e32;
  --muted: #5f7576;
  --cream: #fff8e7;
  --paper: #fffdf5;
  --aqua: #15b8a6;
  --teal: #087e79;
  --deep: #063b43;
  --orange: #ff8f32;
  --yellow: #ffd55b;
  --coral: #ff675f;
  --line: rgba(11, 82, 86, 0.14);
  --shadow: 0 24px 70px rgba(0, 42, 48, 0.18);
}

* { box-sizing: border-box; }

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

body {
  color: var(--ink);
  font-family: "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #e6f8f3;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { width: 1.1em; height: 1.1em; stroke-width: 2.2; }

/* Authentication */
.auth-page {
  min-height: 100dvh;
  padding: 28px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 213, 91, 0.42), transparent 28rem),
    radial-gradient(circle at 88% 84%, rgba(21, 184, 166, 0.34), transparent 32rem),
    #ecfaf6;
}

.auth-shell {
  width: min(1120px, 100%);
  min-height: 690px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(390px, 0.92fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 36px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.auth-visual {
  position: relative;
  padding: 58px;
  overflow: hidden;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(3, 55, 61, 0.18), rgba(3, 55, 61, 0.84)),
    url("assets/juice-lab-background-duo-balanced.webp?v=1") center / cover;
}

.auth-visual::before {
  content: "";
  position: absolute;
  inset: auto -100px -150px auto;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 213, 91, 0.66), transparent 65%);
}

.brand-back {
  position: absolute;
  top: 38px;
  left: 42px;
  color: white;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 800 13px/1 "Manrope", sans-serif;
  letter-spacing: 0.1em;
}

.auth-badge {
  width: fit-content;
  padding: 9px 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(4, 70, 76, 0.56);
  backdrop-filter: blur(10px);
  font: 700 11px/1 "Manrope", sans-serif;
  letter-spacing: 0.13em;
}

.auth-visual h1 {
  margin: 26px 0 14px;
  display: flex;
  flex-direction: column;
  font: 800 clamp(62px, 7vw, 100px)/0.78 "Manrope", sans-serif;
  letter-spacing: -0.075em;
  text-shadow: 0 8px 30px rgba(0, 40, 44, 0.3);
}

.auth-visual h1 strong { color: var(--yellow); }
.auth-visual > p { max-width: 430px; margin: 12px 0 30px; font-size: 18px; line-height: 1.75; }

.auth-feature-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.auth-feature-grid span {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(12px);
  font-size: 12px;
}

.auth-card { padding: 54px; display: flex; flex-direction: column; justify-content: center; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px; border-radius: 16px; background: #edf5f2; }
.auth-tabs a {
  padding: 12px;
  border-radius: 12px;
  color: #668080;
  text-decoration: none;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}
.auth-tabs a[aria-current="page"] { color: var(--deep); background: white; box-shadow: 0 5px 16px rgba(4, 62, 67, 0.09); }
.auth-card-title { margin: 38px 0 26px; display: flex; align-items: center; gap: 14px; }
.auth-card-title > span { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; color: white; background: linear-gradient(135deg, var(--aqua), var(--teal)); box-shadow: 0 10px 24px rgba(21, 184, 166, 0.24); }
.auth-card-title small { color: var(--orange); font: 800 10px/1 "Manrope", sans-serif; letter-spacing: 0.16em; }
.auth-card-title h2 { margin: 5px 0 0; font-size: 24px; letter-spacing: -0.04em; }
.auth-alert { margin: -8px 0 18px; padding: 12px 14px; display: flex; gap: 9px; align-items: center; border-radius: 12px; color: #a53c35; background: #fff0ee; font-size: 13px; }
.auth-form { display: grid; gap: 17px; }
.auth-form label { display: grid; gap: 8px; }
.auth-form label > span { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; }
.auth-form input { width: 100%; padding: 15px 16px; border: 1px solid #d8e7e3; border-radius: 13px; outline: none; color: var(--ink); background: #fbfefd; transition: border-color 0.2s, box-shadow 0.2s; }
.auth-form input:focus { border-color: var(--aqua); box-shadow: 0 0 0 4px rgba(21, 184, 166, 0.12); }
.auth-form button { min-height: 54px; border: 0; border-radius: 15px; color: white; display: flex; align-items: center; justify-content: center; gap: 9px; font-weight: 800; background: linear-gradient(135deg, var(--aqua), var(--teal)); box-shadow: 0 13px 28px rgba(5, 119, 114, 0.22); }
.signup-score { padding: 13px 14px; display: flex; align-items: center; gap: 12px; border-radius: 13px; background: #fff7da; color: #7b5b00; }
.signup-score span { flex: 1; display: grid; gap: 3px; }
.signup-score small { font-size: 10px; }
.signup-score strong { font-size: 13px; }
.auth-switch-copy { margin: 22px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.auth-switch-copy a { color: var(--teal); font-weight: 800; text-decoration: none; }
.auth-switch-copy a svg { vertical-align: -2px; }

/* Game shell */
.game-page {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 18%, rgba(255, 213, 91, 0.23), transparent 28rem),
    radial-gradient(circle at 88% 72%, rgba(21, 184, 166, 0.2), transparent 32rem),
    #eaf9f5;
}

.player-bar {
  position: sticky;
  z-index: 50;
  top: 0;
  min-height: 68px;
  padding: 10px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 18px;
  color: white;
  background: rgba(4, 57, 63, 0.96);
  box-shadow: 0 8px 26px rgba(0, 39, 43, 0.16);
  backdrop-filter: blur(18px);
}

.player-home, .game-logo { color: white; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.player-home { font: 800 12px/1 "Manrope", sans-serif; letter-spacing: 0.08em; }
.game-logo { padding-left: 18px; border-left: 1px solid rgba(255, 255, 255, 0.18); font: 800 16px/1 "Manrope", sans-serif; }
.game-logo b { color: var(--yellow); }
.game-logo > svg { color: var(--yellow); }
.player-data { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 12px; }
.membership, .best { padding: 8px 10px; border-radius: 999px; display: flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, 0.1); }
.membership { color: var(--yellow); font: 800 10px/1 "Manrope", sans-serif; }
.username { font-weight: 800; }
.best b { color: var(--yellow); font-size: 15px; }
.upgrade-button { padding: 10px 13px; border: 0; border-radius: 999px; color: #4b3500; display: flex; align-items: center; gap: 7px; background: linear-gradient(135deg, #ffe790, var(--yellow)); font-size: 12px; font-weight: 800; }
.logout-form button { width: 38px; height: 38px; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 50%; color: white; display: grid; place-items: center; background: rgba(255, 255, 255, 0.08); }

.game-layout { width: min(1250px, 100%); margin: 0 auto; padding: 24px; display: grid; grid-template-columns: 210px minmax(320px, 720px) 210px; justify-content: center; align-items: start; gap: 22px; }
.game-side { position: sticky; top: 92px; display: grid; gap: 16px; }
.side-card { padding: 18px; border: 1px solid rgba(255, 255, 255, 0.9); border-radius: 22px; background: rgba(255, 255, 255, 0.75); box-shadow: 0 15px 40px rgba(6, 59, 67, 0.1); backdrop-filter: blur(14px); }
.side-card h2 { margin: 0 0 14px; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.score-card { text-align: center; background: linear-gradient(160deg, var(--deep), #075e62); color: white; }
.score-card small, .next-side small { font: 800 9px/1 "Manrope", sans-serif; letter-spacing: 0.16em; opacity: 0.72; }
.score-card strong { margin: 7px 0; display: block; color: var(--yellow); font: 800 52px/1 "Manrope", sans-serif; }
.score-card span { padding: 5px 9px; border-radius: 999px; color: var(--deep); background: var(--yellow); font: 800 9px/1 "Manrope", sans-serif; }
.controls-card p { margin: 10px 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.controls-card kbd { min-width: 24px; margin-right: 3px; padding: 3px 5px; border: 1px solid #cfddd9; border-bottom-width: 2px; border-radius: 5px; color: var(--deep); background: white; font: 800 10px/1 "Manrope", sans-serif; }
.controls-card hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.next-side { text-align: center; }
.next-side img { width: 112px; height: 112px; display: block; margin: 6px auto; object-fit: contain; }
.next-side p { color: var(--muted); font-size: 10px; line-height: 1.6; }
.tier-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.tier-list img { width: 100%; aspect-ratio: 1; object-fit: contain; padding: 3px; border-radius: 9px; background: #f5f2df; }

.game-stage-shell { width: 100%; display: grid; justify-items: center; }
.game-stage {
  position: relative;
  width: min(100%, calc((100dvh - 116px) * 0.5625));
  max-width: 720px;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 28px;
  background: url("assets/juice-lab-background-duo-balanced.webp?v=1") center / cover no-repeat;
  box-shadow: 0 28px 65px rgba(0, 49, 54, 0.24), 0 0 0 6px rgba(255, 255, 255, 0.72);
  isolation: isolate;
}

#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.mobile-hud { display: none; }
.next-card { position: absolute; z-index: 5; top: 3.2%; right: 4.2%; width: 78px; padding: 7px 8px 5px; border-radius: 16px; color: var(--deep); text-align: center; background: rgba(255, 253, 239, 0.88); border: 2px solid rgba(255, 255, 255, 0.9); box-shadow: 0 8px 18px rgba(0, 52, 56, 0.15); pointer-events: none; }
.next-card span { display: block; font: 800 9px/1 "Manrope", sans-serif; letter-spacing: 0.12em; }
.next-card img { width: 58px; height: 58px; object-fit: contain; }
.round-control { position: absolute; z-index: 8; top: 3.2%; left: 4.2%; width: 42px; height: 42px; border: 2px solid rgba(255, 255, 255, 0.9); border-radius: 50%; color: var(--deep); display: grid; place-items: center; background: rgba(255, 253, 239, 0.88); box-shadow: 0 8px 18px rgba(0, 52, 56, 0.12); }
.game-overlay { position: absolute; z-index: 20; inset: 0; padding: 24px; display: grid; place-items: center; background: linear-gradient(180deg, rgba(2, 48, 54, 0.28), rgba(2, 48, 54, 0.75)); backdrop-filter: blur(5px); }
.game-overlay[hidden] { display: none; }
.overlay-card { width: min(390px, 88%); padding: 30px; border: 1px solid rgba(255, 255, 255, 0.7); border-radius: 28px; text-align: center; background: rgba(255, 253, 241, 0.94); box-shadow: 0 24px 55px rgba(0, 45, 49, 0.28); }
.overlay-icon { width: 66px; height: 66px; margin: 0 auto 17px; border-radius: 21px; color: white; display: grid; place-items: center; background: linear-gradient(135deg, var(--orange), var(--coral)); box-shadow: 0 14px 30px rgba(255, 103, 95, 0.24); }
.overlay-icon svg { width: 32px; height: 32px; }
.overlay-card > p:first-of-type { color: var(--teal); font: 800 9px/1 "Manrope", sans-serif; letter-spacing: 0.15em; }
.overlay-card h1 { margin: 12px 0; font-size: clamp(24px, 5vw, 34px); line-height: 1.27; letter-spacing: -0.055em; }
.overlay-card #overlay-copy { color: var(--muted); font-size: 12px; line-height: 1.7; }
.overlay-card button { width: 100%; margin-top: 11px; padding: 14px; border: 0; border-radius: 15px; color: white; display: flex; align-items: center; justify-content: center; gap: 8px; background: linear-gradient(135deg, var(--aqua), var(--teal)); font-weight: 800; box-shadow: 0 12px 25px rgba(7, 126, 121, 0.23); }
.score-effects { position: absolute; z-index: 12; inset: 0; pointer-events: none; overflow: hidden; }
.score-pop { position: absolute; color: #fff; font: 800 20px/1 "Manrope", sans-serif; text-shadow: 0 2px 0 #a76300, 0 5px 12px rgba(0, 0, 0, 0.25); animation: score-pop 0.85s ease-out forwards; }
@keyframes score-pop { from { transform: translate(-50%, 0) scale(0.7); opacity: 0; } 20% { opacity: 1; } to { transform: translate(-50%, -64px) scale(1.15); opacity: 0; } }
.mobile-tip { display: none; }

.toast { position: fixed; z-index: 80; top: 86px; left: 50%; transform: translateX(-50%); padding: 12px 16px; border-radius: 999px; display: flex; align-items: center; gap: 8px; color: white; font-size: 13px; font-weight: 800; box-shadow: var(--shadow); }
.toast.success { background: var(--teal); }
.toast.failure { background: #b7473f; }

/* Paywall */
.paywall { position: fixed; z-index: 100; inset: 0; padding: 22px; display: grid; place-items: center; background: rgba(1, 25, 29, 0.78); backdrop-filter: blur(12px); }
.paywall[hidden] { display: none; }
.paywall-card { position: relative; width: min(480px, 100%); padding: 38px; border-radius: 30px; text-align: center; background: linear-gradient(160deg, #fffef7, #fff7d9); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.34); }
.paywall-close { position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); display: grid; place-items: center; background: white; }
.paywall-close[hidden] { display: none; }
.paywall-crown { width: 68px; height: 68px; margin: 0 auto 14px; border-radius: 22px; color: #5e4300; display: grid; place-items: center; background: linear-gradient(135deg, #ffe995, var(--yellow)); }
.paywall-crown svg { width: 34px; height: 34px; }
.paywall-card > p { color: #987000; font: 800 10px/1 "Manrope", sans-serif; letter-spacing: 0.16em; }
.paywall-card h2 { margin: 12px 0 22px; font-size: 29px; line-height: 1.3; letter-spacing: -0.05em; }
.paywall-benefits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.paywall-benefits span { min-height: 80px; padding: 12px 8px; border: 1px solid #eee4c8; border-radius: 14px; display: grid; place-items: center; gap: 5px; background: rgba(255, 255, 255, 0.68); font-size: 10px; font-weight: 700; }
.paywall-benefits svg { color: var(--orange); }
.paywall-price { margin: 16px 0 12px; padding: 16px; border-radius: 15px; display: flex; align-items: center; justify-content: space-between; background: #fff0bc; font-size: 13px; font-weight: 700; }
.paywall-price strong { font: 800 27px/1 "Manrope", sans-serif; }
.paywall-price small { margin-left: 2px; font-size: 12px; }
.purchase-button { width: 100%; padding: 15px; border: 0; border-radius: 15px; color: white; display: flex; justify-content: center; align-items: center; gap: 8px; background: linear-gradient(135deg, #3677ff, #274eda); font-weight: 800; box-shadow: 0 14px 28px rgba(39, 78, 218, 0.23); }
.purchase-button:disabled { opacity: 0.65; }
#payment-status { margin-top: 12px; display: block; color: var(--muted); font-size: 10px; }
#payment-status.is-error { color: #b7473f; }

@media (max-width: 1050px) {
  .game-layout { grid-template-columns: minmax(320px, 720px) 190px; }
  .game-side-left { display: none; }
}

@media (max-width: 820px) {
  .auth-page { padding: 0; }
  .auth-shell { min-height: 100dvh; grid-template-columns: 1fr; border: 0; border-radius: 0; }
  .auth-visual { min-height: 325px; padding: 84px 28px 32px; }
  .auth-visual h1 { font-size: 62px; }
  .auth-visual > p { margin-bottom: 18px; font-size: 15px; }
  .brand-back { top: 27px; left: 26px; }
  .auth-card { padding: 34px 25px 44px; }
  .auth-card-title { margin-top: 28px; }

  .player-bar { min-height: 58px; gap: 9px; }
  .player-home span, .username, .membership, .best { display: none; }
  .game-logo { padding-left: 10px; font-size: 14px; }
  .upgrade-button { margin-left: auto; padding: 9px 11px; }
  .upgrade-button span { font-size: 10px; }
  .player-data { margin-left: auto; gap: 5px; }
  .logout-form button { width: 34px; height: 34px; }

  .game-layout { display: block; padding: 0; }
  .game-side { display: none; }
  .game-stage-shell { display: block; }
  .game-stage { width: min(100vw, calc((100dvh - 58px) * 0.5625)); max-width: none; margin: 0 auto; border-radius: 0; box-shadow: none; }
  .mobile-hud { position: absolute; z-index: 6; top: 2.5%; left: 50%; transform: translateX(-50%); display: flex; gap: 7px; pointer-events: none; }
  .mobile-hud span { min-width: 72px; padding: 7px 10px; border: 2px solid rgba(255, 255, 255, 0.8); border-radius: 13px; text-align: center; background: rgba(4, 57, 63, 0.86); color: white; box-shadow: 0 6px 15px rgba(0, 45, 49, 0.16); }
  .mobile-hud small { display: block; color: var(--yellow); font: 800 7px/1 "Manrope", sans-serif; letter-spacing: 0.12em; }
  .mobile-hud b { font: 800 17px/1.3 "Manrope", sans-serif; }
  .next-card { width: 66px; }
  .next-card img { width: 46px; height: 46px; }
  .round-control { width: 38px; height: 38px; }
  .mobile-tip { margin: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); display: flex; justify-content: center; align-items: center; gap: 7px; color: var(--muted); background: white; font-size: 11px; }
}

@media (max-width: 480px) {
  .auth-feature-grid { display: none; }
  .auth-visual { min-height: 290px; }
  .auth-card { padding-top: 28px; }
  .overlay-card { padding: 24px 20px; }
  .overlay-icon { width: 56px; height: 56px; }
  .paywall-card { padding: 34px 22px 25px; }
  .paywall-benefits { gap: 5px; }
  .paywall-benefits span { padding: 9px 4px; font-size: 9px; }
}

@media (orientation: landscape) and (max-height: 620px) {
  .player-bar { position: relative; }
  .game-stage { width: calc((100dvh - 58px) * 0.5625); }
}

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