/* Idle Car Wash 3D - stage and in-game UI. Everything is scoped under #stage so site styles never leak in. */
html.pip-big, html.pip-big body { overflow: hidden; }
#stage { --sky:#1f8fe0; --sky-d:#1368a8; --sun:#ffd23f; --mint:#3fd98a; --coral:#ff6b6b; --ink:#16304f; --cream:#fff7e0; --panel:rgba(14,32,58,.94);
  position: relative; width: min(100%, calc(78vh * 0.5625)); width: min(100%, calc(78svh * 0.5625)); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden;
  border-radius: 14px; background: linear-gradient(#9fd8ff, #dff2ff); color: var(--cream);
  font-family: "Trebuchet MS", "Segoe UI", Verdana, system-ui, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; line-height: 1.25; }
#stage.is-big { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; z-index: 99999; }
html.pip-immersive #stage { width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; }
html.pip-immersive .game-wrap.pip-stage { display: flex; flex-direction: column; padding: 0; }
html.pip-immersive .game-wrap.pip-stage #stage { flex: 1 1 auto; min-height: 0; }
html.pip-immersive .cw-bar, html.pip-immersive .cw-keys { display: none; }
#stage .fs-x { position: absolute; right: 8px; top: 62px; z-index: 40; min-width: 44px; height: 44px; padding: 0 10px; border-radius: 12px; border: 2px solid rgba(255,255,255,.55); background: rgba(14,32,58,.85); font-weight: 900; font-size: 13px; }
#stage *, #stage *::before, #stage *::after { box-sizing: border-box; }
#stage [hidden] { display: none !important; }
#stage #app { position: absolute; inset: 0; touch-action: none; }
#stage #app canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#stage #ui { position: absolute; inset: 0; pointer-events: none; }
#stage #ui button, #stage #ui .panels, #stage #ui .screen, #stage #ui .tabs { pointer-events: auto; }
#stage button { font-family: inherit; cursor: pointer; touch-action: manipulation; color: inherit; }
#stage button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

#stage #loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: linear-gradient(#1f8fe0, #8fd0ff 60%, #dff2ff); }
#stage .load-in { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-shadow: 0 3px 0 rgba(10,50,100,.45); text-align: center; padding: 0 18px; }
#stage .load-in b { font-size: clamp(20px, 6vw, 30px); letter-spacing: 2px; }
#stage .load-in span { font-size: 14px; }
#stage .spinner { width: 38px; height: 38px; border-radius: 50%; border: 5px solid rgba(255,255,255,.35); border-top-color: #fff; animation: cwspin 0.9s linear infinite; }
@keyframes cwspin { to { transform: rotate(360deg); } }
#stage #ctxlost { position: absolute; left: 12px; right: 12px; top: 40%; z-index: 40; padding: 14px; border-radius: 12px; background: var(--panel); text-align: center; font-size: 14px; }

/* HUD */
#stage .hud { position: absolute; left: 0; right: 0; top: 0; padding: 8px 8px 6px; display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; background: linear-gradient(rgba(10,30,60,.72), rgba(10,30,60,0)); }
#stage .hud-l { min-width: 0; }
#stage .hud-coins { font-size: clamp(22px, 7.5vw, 32px); font-weight: 900; color: var(--sun); text-shadow: 0 2px 0 rgba(0,0,0,.4); display: flex; align-items: center; gap: 6px; line-height: 1.05; }
#stage .hud-coins::before { content: ""; width: .8em; height: .8em; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3a8, #ffb300); border: 2px solid #b97800; flex: none; }
#stage .hud-sub { font-size: 12px; font-weight: 700; color: #e8f5ff; text-shadow: 0 1px 0 rgba(0,0,0,.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .hud-r { display: flex; gap: 6px; flex: none; }
#stage .ib { min-width: 44px; height: 44px; padding: 0 8px; border-radius: 12px; border: 2px solid rgba(255,255,255,.55); background: rgba(14,32,58,.78); font-weight: 900; font-size: 13px; }
#stage .ib.off { opacity: .6; text-decoration: line-through; }
#stage .hud-bar { position: absolute; left: 8px; right: 8px; bottom: -2px; height: 6px; border-radius: 3px; background: rgba(0,0,0,.35); overflow: visible; }
#stage .hud-fill { height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, #3fd98a, #ffd23f); }
#stage .tk { position: absolute; top: -3px; width: 4px; height: 12px; margin-left: -2px; background: #cfd8e6; border-radius: 2px; }
#stage .tk.got { background: var(--sun); }
#stage .rush-tag { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); padding: 3px 12px; border-radius: 999px; background: var(--coral); color: #fff; font-weight: 900; font-size: 12px; letter-spacing: 1px; animation: cwpulse 1s ease-in-out infinite; }
@keyframes cwpulse { 50% { transform: translateX(-50%) scale(1.08); } }
#stage .hint { position: absolute; left: 10px; right: 10px; top: 92px; padding: 8px 12px; border-radius: 12px; background: rgba(255,247,224,.96); color: var(--ink); font-weight: 800; font-size: 13px; text-align: center; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
#stage .banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; pointer-events: none; opacity: 0; transform: scale(.85); transition: opacity .25s, transform .25s; color: #fff; text-shadow: 0 3px 0 rgba(10,40,90,.6); }
#stage .banner.show { opacity: 1; transform: scale(1); }
#stage .b-main { font-size: clamp(24px, 8vw, 38px); font-weight: 900; letter-spacing: 2px; }
#stage .b-sub { font-size: 14px; font-weight: 700; }
#stage .feed { position: absolute; left: 10px; right: 10px; top: 128px; display: flex; flex-direction: column; gap: 4px; align-items: center; pointer-events: none; }
#stage .toast { padding: 6px 12px; border-radius: 999px; background: rgba(14,32,58,.9); font-size: 12px; font-weight: 800; border: 2px solid rgba(255,255,255,.4); text-align: center; }
#stage .toast.star, #stage .toast.mission { border-color: var(--sun); color: var(--sun); }
#stage .toast.vip { border-color: #ffd23f; }
#stage .pop { position: absolute; transform: translate(-50%, -50%); pointer-events: none; font-weight: 900; font-size: 15px; color: var(--sun); text-shadow: 0 2px 0 rgba(0,0,0,.6); animation: cwpop 1s ease-out forwards; }
#stage .pop.vip { color: #fff; font-size: 18px; text-shadow: 0 2px 0 #b96a00; }
@keyframes cwpop { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -46px; } }

/* dock */
#stage .dock { position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 3px solid rgba(255,255,255,.18); border-radius: 16px 16px 0 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
#stage .quick { display: flex; gap: 6px; }
#stage .q { position: relative; flex: 1; min-height: 44px; border-radius: 12px; border: 2px solid rgba(255,255,255,.28); background: #22406b; font-weight: 900; font-size: 13px; overflow: hidden; }
#stage .q-qty { flex: 0 0 62px; }
#stage .q-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: rgba(63,217,138,.35); transform-origin: left; }
#stage .q-txt { position: relative; }
#stage .q.ready { border-color: var(--mint); }
#stage .q-turbo.on { background: #8a4b00; border-color: var(--sun); }
#stage .q-best:not(.ready) { opacity: .6; }
#stage .tabs { display: flex; gap: 4px; }
#stage .tab { position: relative; flex: 1; min-height: 44px; border-radius: 10px; border: 2px solid transparent; background: #1a3358; font-weight: 800; font-size: 13px; }
#stage .tab.on { background: var(--sky); border-color: #fff; }
#stage .dot { position: absolute; right: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--coral); border: 2px solid #fff; }
#stage .panels { max-height: clamp(120px, 22vh, 230px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
@supports (height: 1svh) { #stage .panels { max-height: clamp(120px, 22svh, 230px); } }
#stage .dock.closed .panels { display: none; }
#stage .panel { display: flex; flex-direction: column; gap: 5px; padding-bottom: 2px; }
#stage .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(255,255,255,.07); min-height: 48px; }
#stage .row.locked { opacity: .55; }
#stage .r-l { flex: 1; min-width: 0; }
#stage .r-r { display: flex; align-items: center; gap: 8px; flex: none; }
#stage .r-name { font-weight: 900; font-size: 14px; }
#stage .r-info { font-size: 11px; opacity: .85; }
#stage .note { padding: 2px 6px; }
#stage .buy { min-height: 44px; min-width: 96px; padding: 0 10px; border-radius: 10px; border: 2px solid #1b7a4c; background: var(--mint); color: #05301d; font-weight: 900; font-size: 13px; flex: none; }
#stage .buy.dim, #stage .buy:disabled { background: #46566e; border-color: #2c3a4f; color: #c7d2e2; }
#stage .buy.go { background: var(--sun); border-color: #a87400; color: #3a2800; }
#stage .buy.big { width: 100%; }
#stage .tier-row { display: flex; gap: 4px; align-items: center; padding: 2px 4px; }
#stage .tier-row .r-name { width: 48px; }
#stage .tier { flex: 1; min-height: 44px; border-radius: 10px; border: 2px solid rgba(255,255,255,.25); background: #22406b; font-weight: 800; font-size: 11px; }
#stage .tier.on { background: var(--sky); border-color: #fff; }
#stage .tier.dim { opacity: .55; }
#stage .card { padding: 8px; border-radius: 10px; background: rgba(255,255,255,.09); display: flex; flex-direction: column; gap: 5px; }
#stage .mbar { height: 8px; border-radius: 4px; background: rgba(0,0,0,.4); overflow: hidden; margin-top: 3px; }
#stage .mfill { height: 100%; width: 0; background: var(--mint); }
#stage .achs { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 2px 4px; }
#stage .ach { padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: rgba(255,255,255,.08); opacity: .5; }
#stage .ach.got { background: rgba(255,210,63,.25); opacity: 1; color: var(--sun); }
#stage .ach-head { padding: 4px 6px 0; }

/* screens */
#stage .screen { position: absolute; inset: 0; z-index: 30; background: rgba(8,22,44,.9); overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; display: flex; align-items: flex-start; justify-content: center; padding: 14px 12px; }
#stage .sbox { width: 100%; max-width: 420px; margin: auto; display: flex; flex-direction: column; gap: 8px; }
#stage .s-head { text-align: center; margin-bottom: 2px; }
#stage .s-title { font-size: clamp(24px, 8vw, 34px); font-weight: 900; color: var(--sun); text-shadow: 0 3px 0 rgba(0,0,0,.45); }
#stage .s-sub { font-size: 13px; opacity: .9; }
#stage .s-label { font-size: 12px; font-weight: 800; letter-spacing: .5px; opacity: .8; margin-top: 4px; }
#stage .s-foot { display: flex; gap: 8px; }
#stage .s-foot .sm { flex: 1; min-height: 44px; border-radius: 10px; border: 2px solid rgba(255,255,255,.3); background: #22406b; font-weight: 800; }
#stage .big { width: 100%; min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 2px solid rgba(255,255,255,.35); background: #22406b; font-weight: 900; font-size: 16px; }
#stage .big.go { background: var(--mint); border-color: #1b7a4c; color: #05301d; }
#stage .big.warn { background: #6b2230; border-color: #b04559; }
#stage .notice { padding: 8px 10px; border-radius: 10px; background: rgba(255,210,63,.16); border: 1px solid rgba(255,210,63,.5); font-size: 13px; font-weight: 700; text-align: center; }
#stage .notice.goal { background: rgba(63,217,138,.15); border-color: rgba(63,217,138,.5); }
#stage .line { text-align: center; font-size: 13px; }
#stage .score { text-align: center; font-size: clamp(34px, 12vw, 52px); font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.4); }
#stage .help-p { font-size: 14px; line-height: 1.45; }
#stage .medals { display: inline-flex; gap: 4px; justify-content: center; }
#stage .md { width: 16px; height: 16px; border-radius: 50%; background: #3a4a62; border: 2px solid #5b6b85; display: inline-block; }
#stage .md.got.m1 { background: #cd8a4f; border-color: #8a5524; }
#stage .md.got.m2 { background: #d6dde8; border-color: #8c98aa; }
#stage .md.got.m3 { background: var(--sun); border-color: #b98700; }
#stage .s-results .medals { align-self: center; }

.cw-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: .75rem 0 .25rem; }
.cw-bar .btn { min-height: 44px; min-width: 44px; }
.cw-keys { text-align: center; font-size: .8rem; color: #64748b; margin: .25rem 0 0; }
.cw-guide { max-width: 640px; margin: 1.5rem auto; padding: 0 1rem; line-height: 1.6; }
.cw-guide h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.cw-guide h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.cw-guide p { margin-bottom: .5rem; font-size: .95rem; }

@media (prefers-reduced-motion: reduce) { #stage .pop, #stage .rush-tag, #stage .spinner { animation: none; } #stage .banner { transition: none; } }

/* next goal chip: saving-for line under the coin counter */
#stage .goal-chip { position: relative; display: block; margin-top: 4px; max-width: min(100%, 62vw); min-height: 30px; padding: 5px 12px; border-radius: 999px; border: 2px solid rgba(255,255,255,.5); background: rgba(14,32,58,.82); color: #fff; font-size: 12px; font-weight: 800; text-align: left; overflow: hidden; cursor: pointer; }
#stage .goal-chip[hidden] { display: none; }
#stage .goal-chip::before { content: ""; position: absolute; left: -8px; right: -8px; top: -8px; bottom: -8px; }
#stage .goal-chip .gc-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, rgba(63,217,138,.55), rgba(255,210,63,.55)); }
#stage .goal-chip .gc-txt { position: relative; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage .goal-chip.ready { border-color: var(--mint); animation: cwchip 1.2s ease-in-out infinite; }
@keyframes cwchip { 50% { box-shadow: 0 0 0 4px rgba(63,217,138,.35); } }
#stage .rush-tag { top: 108px; }
#stage .hint { top: 138px; }
@media (prefers-reduced-motion: reduce) { #stage .goal-chip.ready { animation: none; } }
#stage .feed { top: 176px; }
/* Pass 3: full screen on phones. Native and immersive modes fill the stage, hide page chrome and the duplicate button. */
html.pip-native #stage, #stage:fullscreen { width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; }
html.pip-native .cw-bar, html.pip-native .cw-keys, html.pip-immersive .cw-bar, html.pip-immersive .cw-keys, html.pip-native .game-header, html.pip-immersive .game-header, html.pip-native .ad-well, html.pip-immersive .ad-well, html.pip-native .cw-guide, html.pip-immersive .cw-guide { display: none !important; }
html.pip-native #stage .hud, html.pip-immersive #stage .hud { padding-top: calc(8px + env(safe-area-inset-top, 0px)); padding-left: calc(8px + env(safe-area-inset-left, 0px)); padding-right: calc(8px + env(safe-area-inset-right, 0px)); }
html.pip-native #stage .dock, html.pip-immersive #stage .dock { padding-left: calc(8px + env(safe-area-inset-left, 0px)); padding-right: calc(8px + env(safe-area-inset-right, 0px)); }
@media (orientation: landscape) and (max-height: 520px) {
  html.pip-native #stage .panels, html.pip-immersive #stage .panels { max-height: 78px; }
}
