:root {
  --bg: #0f2a26; --ink: #f4fff8; --soft: #b9d8cc; --card: rgba(10, 28, 30, 0.82); --line: rgba(190, 255, 220, 0.16);
  --gold: #ffd54a; --accent: #8ee07a; --accent2: #ffe38a; --danger: #ff9a8a;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
canvas#cv { position: fixed; inset: 0; display: block; touch-action: none; cursor: crosshair; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 56px 16px 16px; gap: 12px; background: radial-gradient(ellipse at center, rgba(8, 20, 24, 0.25), rgba(4, 10, 14, 0.75)); overflow-y: auto; z-index: 5; }
.screen > .card { margin-top: auto; }
.screen > :last-child { margin-bottom: auto; }
.card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px 20px 18px;
  backdrop-filter: blur(8px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06); text-align: center;
  animation: rise .45s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; }
.glow-dot { width: 18px; height: 18px; border-radius: 50%; background: #fff6b0; box-shadow: 0 0 12px 4px #ffe36e, 0 0 32px 10px rgba(255, 220, 90, .45);
  animation: blink 2.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .55; transform: scale(.85); } }
.title { margin: 0; font-size: clamp(28px, 7vw, 38px); letter-spacing: -0.5px; font-weight: 800;
  background: linear-gradient(180deg, #fffbe0, #b9f7c9 60%, #8fd8ff); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 24px rgba(180, 255, 200, .25); }
.tag { margin: 6px 0 10px; color: var(--soft); }
.online { margin: 0 0 14px; color: var(--soft); font-size: 14px; }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 4px; box-shadow: 0 0 8px var(--accent); animation: blink 1.6s infinite; }
#nameIn { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.3); color: var(--ink);
  font-size: 17px; text-align: center; outline: none; }
#nameIn:focus { border-color: rgba(190, 255, 210, .5); box-shadow: 0 0 0 3px rgba(142, 224, 122, .18); }
.skins-h { margin: 14px 0 6px; font-size: 13px; color: var(--soft); }
.skins-h small { opacity: .8; }
.skins { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.skin { aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; padding: 0; position: relative; background: #223; overflow: hidden; }
.skin canvas { width: 100%; height: 100%; display: block; }
.skin[aria-selected="true"] { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .18), 0 0 14px rgba(255, 245, 180, .5); }
.skin.locked { filter: grayscale(.85) brightness(.55); cursor: not-allowed; }
.skin.locked::after { content: "🔒"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; }
.play { margin-top: 16px; width: 100%; padding: 15px; border: 0; border-radius: 16px; font-size: 19px; font-weight: 800; color: #10301f;
  background: linear-gradient(180deg, #c8ffb0, #7fdc6a); box-shadow: 0 6px 0 #4f9c42, 0 10px 24px rgba(127, 220, 106, .35); transition: transform .08s, box-shadow .08s; }
.play:active { transform: translateY(4px); box-shadow: 0 2px 0 #4f9c42, 0 6px 14px rgba(127, 220, 106, .3); }
.play:disabled { filter: grayscale(.6); opacity: .7; }
.how { margin: 12px 0 2px; font-size: 13px; color: var(--soft); }
.best { margin: 8px 0 0; font-size: 14px; color: var(--accent2); }
.note { margin: 8px 0 0; font-size: 12px; color: rgba(185, 216, 204, .7); }
.msg { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 200, 120, .12); border: 1px solid rgba(255, 200, 120, .3); color: #ffe2b0; font-size: 14px; }
.foot { font-size: 13px; color: var(--soft); }
.foot a { color: var(--soft); }
.ad-slot { width: min(728px, 100%); min-height: 90px; }

.over-t { margin: 0; font-size: 30px; font-weight: 800; color: #fffbe0; }
.over-s { margin: 4px 0 12px; color: var(--soft); }
.badge { display: inline-block; margin-bottom: 10px; padding: 5px 12px; border-radius: 999px; background: linear-gradient(90deg, #ffe38a, #ffb86b); color: #3a2400; font-weight: 800; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats div { background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; }
.stats small { display: block; color: var(--soft); font-size: 12px; }
.stats b { font-size: 22px; }
.unlock { margin-top: 12px; padding: 10px; border-radius: 14px; background: rgba(200, 160, 255, .12); border: 1px solid rgba(200, 160, 255, .35); }
.reward { margin-top: 10px; width: 100%; padding: 11px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); }

.langsw { position: fixed; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 6; display: flex; align-items: center; gap: 2px;
  padding: 3px 6px; border-radius: 999px; background: rgba(6, 18, 20, .6); border: 1px solid var(--line); font-size: 13px; color: var(--soft); }
.langsw button { border: 0; background: none; padding: 4px 8px; border-radius: 999px; color: var(--soft); }
.langsw button[aria-pressed="true"] { background: rgba(190, 255, 210, .16); color: #fff; font-weight: 700; }
body.ingame .langsw, body.ingarden .langsw { display: none; }

.today, .overboard { margin: 0 0 12px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); text-align: left; font-size: 13.5px; }
.overboard { margin: 12px 0 0; }
.today-h, .board-h { font-size: 12px; color: var(--soft); letter-spacing: .02em; }
.today-h { margin-bottom: 2px; }
#todayGarden { font-weight: 700; color: #fffbe0; }
.rule { color: #d9ffe6; margin-top: 2px; }
.board-h { margin-top: 8px; }
.board-h b { color: var(--accent2); margin-left: 4px; }
.daytop { margin: 2px 0 0; padding-left: 0; list-style: none; counter-reset: r; }
.daytop li { display: flex; gap: 6px; counter-increment: r; }
.daytop li::before { content: counter(r) '.'; min-width: 18px; color: var(--soft); }
.daytop li.empty::before { content: none; } .daytop li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.daytop li b { font-variant-numeric: tabular-nums; color: var(--accent2); }
.daytop li.me { color: #fff6b0; font-weight: 700; }
.daytop .empty { color: var(--soft); }
.yday { margin-top: 4px; font-size: 12px; color: var(--soft); }
.chip { position: absolute; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); padding: 6px 14px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 230, 120, .9), rgba(255, 190, 90, .9)); color: #3a2400; font-weight: 800; font-size: 13.5px; white-space: nowrap;
  box-shadow: 0 0 18px rgba(255, 210, 90, .5); animation: pop .4s cubic-bezier(.2, 1.6, .4, 1) both; }
@media (max-width: 600px) { .chip { top: auto; bottom: 130px; } }

.modebox { margin: 0 0 10px; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, .28); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 7px 16px; border-radius: 999px; color: var(--soft); font-weight: 600; }
.seg button[aria-pressed="true"] { background: rgba(190, 255, 210, .18); color: #fff; }
.seg.small button { padding: 4px 11px; }
.teamopts { margin-top: 8px; font-size: 13px; color: var(--soft); }
.teamhint { margin: 6px 0 0; font-size: 12.5px; }
.ghostbtn { margin-top: 10px; width: 100%; padding: 11px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); font-weight: 600; }
.friendban { margin: 0 0 10px; padding: 9px 12px; border-radius: 14px; background: rgba(255, 220, 120, .12); border: 1px solid rgba(255, 220, 120, .35); font-size: 13.5px; }
.linkbtn { display: block; margin: 6px auto 0; border: 0; background: none; color: var(--soft); text-decoration: underline; font-size: 12.5px; }
.over-team { margin: -4px 0 10px; font-weight: 700; }
.teambar { position: absolute; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); display: flex; width: min(380px, 46vw); height: 22px;
  border-radius: 999px; overflow: hidden; border: 1px solid rgba(255, 255, 255, .25); background: rgba(0, 0, 0, .3); font-size: 11.5px; font-weight: 800; color: #1b1426; }
.teambar div { display: flex; align-items: center; justify-content: center; min-width: 28px; transition: flex-grow .6s; white-space: nowrap; overflow: hidden; }
.teambar div.mine { box-shadow: inset 0 0 0 2px #fff; }
.invite { position: absolute; left: max(12px, env(safe-area-inset-left)); top: 106px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(6, 18, 20, .6); font-size: 13px; font-weight: 700; color: #fffbe0; }
.toast { position: fixed; z-index: 9; left: 50%; top: 40%; transform: translateX(-50%); padding: 10px 16px; border-radius: 14px; background: rgba(6, 18, 20, .85); border: 1px solid var(--line); font-size: 14px; }
body:has(.teambar:not([hidden])) .chip { top: 44px; }
@media (max-width: 600px) { .teambar { top: auto; bottom: 108px; width: 62vw; } .board li { font-size: 11px; } }

.dewgot { margin: 12px 0 0; font-size: 15px; color: #d9f4ff; }
.dewgot b { font-size: 20px; color: #9ad8ff; }
.dewgot small { display: block; color: var(--accent2); font-weight: 700; margin-top: 2px; }
#gardenBtn small { color: #9ad8ff; }
.garden { background: rgba(4, 12, 14, .82); }
.card.wide { width: min(760px, 100%); text-align: left; }
.g-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.g-head h2 { margin: 0 auto 0 0; font-size: 24px; color: #fffbe0; }
.pill { padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); font-size: 13px; }
.pill.dew b { color: #9ad8ff; font-size: 15px; }
.g-next { margin: 4px 0 8px; font-size: 13px; color: var(--soft); }
.g-cv { display: block; width: 100%; aspect-ratio: 5 / 4; border-radius: 16px; border: 1px solid var(--line); cursor: pointer; touch-action: manipulation; }
.g-info { min-height: 22px; margin: 8px 0; font-size: 13.5px; color: #e4fff0; }
.g-info button { margin-left: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); font-size: 12.5px; }
.shelf { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.shelf-it { position: relative; padding: 4px 2px 6px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); font-size: 11.5px; line-height: 1.25; text-align: center; }
.shelf-it canvas { width: 100%; aspect-ratio: 1; border-radius: 9px; display: block; margin-bottom: 3px; }
.shelf-it.on { border-color: #fff3b0; box-shadow: 0 0 0 2px rgba(255, 240, 170, .4); }
.shelf-it.locked { filter: grayscale(.8) brightness(.6); }
.shelf-it i { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); font-style: normal; font-weight: 700; font-size: 11px; background: rgba(0, 0, 0, .6); padding: 1px 6px; border-radius: 999px; }
.shelf-it b { color: #9ad8ff; } .shelf-it b.poor { color: #ff9a8a; }
.g-key { margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); font-size: 13px; }
.g-key p { margin: 0 0 6px; color: var(--soft); }
.g-key .ghostbtn { width: auto; margin: 0; padding: 7px 12px; }
.keyout { margin-left: 8px; letter-spacing: .12em; color: #fff6b0; }
.keyrow { display: flex; gap: 6px; margin-top: 8px; }
.keyrow input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, .3); color: var(--ink); letter-spacing: .1em; text-transform: uppercase; }
.keyrow button { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .08); }
@media (max-width: 600px) { .shelf { grid-template-columns: repeat(4, 1fr); } .card.wide { padding: 14px 12px; } }

/* ---------- in-game HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
#hud button { pointer-events: auto; }
.hud-tl { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.score { font-size: 15px; color: var(--soft); }
.score b { font-size: 24px; color: #fff; font-variant-numeric: tabular-nums; }
.rankline { font-size: 13px; color: var(--soft); }
.board { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); margin: 0; padding: 8px 10px 8px 30px;
  min-width: 170px; max-width: 46vw; background: rgba(6, 18, 20, .45); border: 1px solid var(--line); border-radius: 14px; font-size: 13px; backdrop-filter: blur(4px); }
.board li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; color: #dff; }
.board li span.n { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.board li b { font-variant-numeric: tabular-nums; color: var(--soft); font-weight: 600; }
.board li.me { color: #fff6b0; font-weight: 700; }
.board li.first::before { content: "👑"; margin-left: -22px; width: 16px; }
.mini { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); width: 120px; height: 120px; opacity: .92; }
.netinfo { position: absolute; left: 140px; bottom: max(14px, env(safe-area-inset-bottom)); font-size: 11px; color: rgba(185, 216, 204, .55); font-variant-numeric: tabular-nums; }
.iconbtn { position: absolute; left: max(12px, env(safe-area-inset-left)); top: 64px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(6, 18, 20, .45); font-size: 16px; }
.iconbtn.off { opacity: .45; text-decoration: line-through; }
.boost { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 84px; height: 84px; border-radius: 50%;
  border: 2px solid rgba(255, 240, 170, .45); background: radial-gradient(circle at 40% 35%, rgba(255, 245, 190, .35), rgba(255, 200, 80, .12)); font-size: 34px;
  display: none; touch-action: none; user-select: none; -webkit-user-select: none; }
.boost.on { background: radial-gradient(circle at 40% 35%, rgba(255, 250, 210, .7), rgba(255, 200, 80, .35)); transform: scale(.94); }
.touch .boost { display: block; }
.joy { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .05); }
.joy .knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(255, 250, 210, .35); box-shadow: 0 0 14px rgba(255, 240, 160, .4); }
.hint { position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 8px 14px; border-radius: 999px;
  background: rgba(6, 18, 20, .55); color: var(--soft); font-size: 13px; transition: opacity 1s; max-width: min(560px, 80vw); text-align: center; border-radius: 14px; width: max-content; }
.hint.gone { opacity: 0; }
@media (max-height: 700px), (max-width: 360px) {
  .today { padding: 7px 10px; margin-bottom: 8px; font-size: 12.5px; }
  .board-h { margin-top: 4px; }
  .today .board-h { display: inline; } .today .daytop { display: inline; } .today .daytop li:nth-child(n+2) { display: none; }
  .today .daytop li { display: inline-flex; margin-left: 6px; } .today .daytop li::before { content: '👑'; min-width: 0; }
  .today-h { display: none; }
  .screen { padding-top: 50px; gap: 8px; }
  .card { padding: 14px 14px 12px; border-radius: 18px; }
  .title { font-size: 26px; }
  .tag { margin: 4px 0 6px; font-size: 14px; }
  .online { margin-bottom: 8px; }
  #nameIn { padding: 10px; font-size: 16px; }
  .skins-h { margin: 8px 0 4px; }
  .skins { gap: 6px; }
  .play { margin-top: 10px; padding: 12px; font-size: 18px; }
  .how, .note { font-size: 12px; }
}
@media (max-width: 600px) {
  .board { font-size: 11.5px; min-width: 128px; padding: 6px 8px 6px 26px; }
  .board li:nth-child(n+6) { display: none; }
  .mini { width: 92px; height: 92px; }
  .netinfo { left: 112px; }
  .score b { font-size: 20px; }
  .hint { bottom: 120px; }
  body:has(.teambar:not([hidden])) .hint { bottom: 140px; }
}

/* ---------- info pages ---------- */
body.page { overflow: auto; height: auto; }
.page main { max-width: 760px; margin: 0 auto; padding: 28px 16px 60px; }
.page h1 { color: #fffbe0; } .page h2 { color: #d9ffe6; margin-top: 28px; }
.page a { color: #b9f7c9; } .page p, .page li { color: #d6eee4; }

/* Korean: wrap between words, never inside one */
html:lang(ko) body { word-break: keep-all; overflow-wrap: break-word; }

/* ---------- share result / challenge a friend ---------- */
.chban { margin: 0 0 10px; padding: 10px 12px; border-radius: 14px; background: linear-gradient(135deg, rgba(255, 210, 120, .16), rgba(160, 230, 255, .1));
  border: 1px solid rgba(255, 220, 140, .45); font-size: 14px; text-align: left; word-break: keep-all; overflow-wrap: anywhere; }
.chban b { display: block; color: #fff3c4; }
.chban small { display: block; margin-top: 3px; color: var(--soft); font-size: 12.5px; }
.chban small.ok { color: #a8f0c0; } .chban small.warn { color: #ffc49a; }
.vs { margin: 10px 0 0; padding: 9px 12px; border-radius: 14px; font-weight: 700; font-size: 15px; word-break: keep-all; overflow-wrap: anywhere;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line); }
.vs.win { background: rgba(255, 220, 110, .16); border-color: rgba(255, 220, 110, .5); color: #fff1b8; }
.vs small { display: block; font-weight: 500; font-size: 12px; color: var(--soft); margin-top: 2px; }
.sharerow { display: flex; gap: 8px; }
.sharerow .ghostbtn { flex: 1 1 0; min-width: 0; padding: 11px 6px; }
.sharebox { margin-top: 8px; text-align: left; }
.sharebox small { color: var(--soft); font-size: 12px; }
.sharebox textarea { display: block; width: 100%; margin-top: 4px; padding: 8px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .35); color: #fffbe0; font: 12.5px/1.45 ui-monospace, Consolas, monospace; resize: none; box-sizing: border-box; }
body.portal #shareRow, body.portal #shareBoxWrap, body.portal #friendsBtn, body.portal #inviteBtn, body.portal #chBanner { display: none !important; }

/* 첫 화면 아래 「하는 법」 (검색·처음 온 분용, 눈에 보임) */
.intro { width: min(560px, 100%); color: var(--soft); font-size: 14px; line-height: 1.65; text-align: left; padding: 8px 4px 24px; }
.intro h2 { font-size: 17px; color: inherit; margin: 6px 0; } .intro ul { padding-left: 18px; margin: 6px 0; } .intro li { margin: 4px 0; }
html[lang="ko"] .intro [data-only="en"], html:not([lang="ko"]) .intro [data-only="ko"] { display: none; }
body.portal .intro, body:not(.gg-ready) .intro { display: none; }  /* shown once the start card is filled, so it never pushes things around */
