:root {
  --green: #7cc242; --green-d: #5da02e; --green-dd: #3c7a28; --ink: #223320; --muted: #667a62;
  --bg: #f1f6ec; --card: #ffffff; --line: #dfe8d8; --gold: #ffc83d; --bad: #e5594f; --good: #3fae49;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', Arial, sans-serif; color: var(--ink); background: linear-gradient(160deg, #cfe8bd, #9ccc86 55%, #6aa65a); overscroll-behavior: none; }
#shell { height: 100dvh; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; background: var(--bg); position: relative; box-shadow: 0 0 40px rgba(0,0,0,.18); overflow: hidden; }
#view { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
body.full #view { overflow: hidden; }
body.full #tabs { display: none; }
#tabs { display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; border: 0; background: none; padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 12px; font-weight: 600; position: relative; cursor: pointer; }
.tab.on { color: var(--green-dd); }
.tab .dot { position: absolute; top: 6px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--bad); border: 2px solid #fff; }
.ic { width: 22px; height: 22px; flex: none; }
h1, h2, h3 { margin: 0; }
button { font: inherit; color: inherit; }
.hidden { display: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.left { text-align: left; }
.center-text { text-align: center; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.center { align-items: center; }
.row.center-x { justify-content: center; }
.row.gap, .gap { gap: 8px; }
.row.wrap, .wrap { flex-wrap: wrap; }
.mt { margin-top: 10px; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.err { color: var(--bad); font-size: 13px; min-height: 16px; }

/* ---------- pages */
.page { padding: 14px 14px 22px; display: flex; flex-direction: column; gap: 10px; }
.page-head { display: flex; align-items: center; gap: 10px; }
.page-head h2 { flex: 1; font-size: 22px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { font-size: 28px; font-weight: 900; letter-spacing: -.5px; color: var(--green-dd); }
.logo span { color: var(--gold); text-shadow: 0 1px 0 #c99a14; }
.lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-top: 6px; }
.card-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.card-box summary { cursor: pointer; font-weight: 600; }
.empty { text-align: center; padding: 30px 10px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.big { font-size: 44px; }

/* ---------- buttons */
.btn { background: var(--green); color: #fff; border: 0; border-bottom: 3px solid var(--green-d); border-radius: 12px; padding: 10px 16px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.btn:active { transform: translateY(1px); border-bottom-width: 2px; }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.big { padding: 14px 18px; font-size: 17px; }
.btn.alt { background: #fff; color: var(--green-dd); border: 2px solid var(--green); border-bottom-width: 3px; }
.btn.ghost { background: transparent; color: var(--muted); border: 0; }
.btn.danger { color: var(--bad); }
.btn.good { background: var(--good); border-bottom-color: #2b8a35; }
.btn.bad { background: var(--bad); border-bottom-color: #b9423a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-grid .big { grid-column: span 1; }
.link { background: none; border: 0; color: var(--green-dd); text-decoration: underline; cursor: pointer; padding: 0; }
.icon-btn { background: #fff; border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); flex: none; }
.icon-btn.on { background: var(--green); color: #fff; border-color: var(--green); }
.icon-btn.glass { background: rgba(0,0,0,.28); border: 0; color: #fff; }
.input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--ink); }
.input:focus { outline: 2px solid var(--green); border-color: var(--green); }
.input.small { width: auto; padding: 5px 8px; font-size: 14px; max-width: 160px; }
.pill { border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.pill.on { background: var(--green); color: #fff; border-color: var(--green-d); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip { font-size: 11px; background: #e7f0df; color: var(--green-dd); padding: 2px 8px; border-radius: 999px; font-weight: 600; margin-left: 6px; }
.chip.warn { background: #fff0c9; color: #8a5f00; margin: 0; align-self: flex-start; }
.chip.ok { background: #e1f5e3; color: #2b8a35; margin: 0; align-self: flex-start; }
.badge { font-size: 11px; font-weight: 800; background: #223320; color: #fff; border-radius: 6px; padding: 2px 6px; }
.lvl { font-size: 10px; font-weight: 800; border-radius: 5px; padding: 1px 5px; color: #fff; background: #8fbf6a; }
.lvl.l2 { background: #5fb3a1; } .lvl.l3 { background: #5b92d6; } .lvl.l4 { background: #a773d6; } .lvl.l5 { background: #d6684f; }
.bar { height: 6px; background: #e3ecda; border-radius: 99px; overflow: hidden; }
.bar.thick { height: 10px; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .3s; }
.dots { display: inline-flex; gap: 2px; } .dots i { width: 6px; height: 6px; border-radius: 50%; background: #d4dfca; } .dots i.on { background: var(--green); }
.switch-row { display: flex; align-items: center; justify-content: space-between; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.switch-row span { display: flex; align-items: center; gap: 6px; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--green-d); }

/* ---------- play menu */
.chip-top { display: inline-flex; align-items: center; gap: 4px; background: rgba(0,0,0,.3); color: #fff; padding: 5px 10px; border-radius: 999px; font-weight: 800; font-size: 14px; border: 0; }
.chip-top .ic { width: 18px; height: 18px; color: var(--gold); }
.chip-top.dark { background: #223320; }
.daily-card { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px dashed var(--line); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; width: 100%; }
.daily-card .ic { width: 30px; height: 30px; color: #d6684f; }
.daily-card.ready { border: 2px solid var(--gold); background: linear-gradient(90deg, #fff8e0, #fff); animation: glow 1.8s infinite; }
.streak { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; color: #e0731d; } .streak .ic { width: 18px; height: 18px; }
@keyframes glow { 50% { box-shadow: 0 0 0 5px rgba(255,200,61,.35); } }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-card { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.mode-card.on { border-color: var(--green); background: #f4fbec; box-shadow: 0 0 0 3px rgba(124,194,66,.25); }
.mode-card .flags { font-weight: 900; font-size: 18px; display: flex; gap: 6px; align-items: center; } .mode-card .flags i { font-style: normal; color: var(--green-d); }
.mname { font-weight: 700; } .msub { font-size: 12px; color: var(--muted); line-height: 1.25; } .mlvl { font-size: 12px; font-weight: 700; color: var(--green-dd); margin-top: 2px; }
.cta { position: sticky; bottom: 0; padding: 10px 0 0; background: linear-gradient(transparent, var(--bg) 35%); }
.cta-btn { width: 100%; }

/* ---------- decks */
.deck-list { display: grid; gap: 8px; }
.deck-tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 6px; text-align: left; cursor: pointer; width: 100%; }
.stat-row { display: flex; gap: 8px; } .stat-row div { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; align-items: center; } .stat-row b { font-size: 20px; } .stat-row span { font-size: 12px; color: var(--muted); }
.card-rows, .word-rows { display: flex; flex-direction: column; gap: 6px; }
.card-row, .word-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.word-row.in { background: #f1faea; border-color: #bfe0a5; }
.scroll-y { overflow-y: auto; max-height: 38vh; display: flex; flex-direction: column; gap: 6px; padding: 2px; }

/* ---------- account */
.auth { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; } .tile b { font-size: 20px; } .tile span { font-size: 12px; color: var(--muted); }

/* ---------- modal */
.modal-back { position: fixed; inset: 0; background: rgba(15,30,10,.55); display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 50; opacity: 0; transition: opacity .15s; }
.modal-back.in { opacity: 1; }
.modal-box { background: #fff; border-radius: 18px; padding: 16px; width: min(480px, 100%); max-height: 92dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.35); animation: rise .18s ease-out; }
@keyframes rise { from { transform: translateY(14px) scale(.98); opacity: .5; } }
.win-head { text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day { border: 1.5px solid var(--line); border-radius: 10px; padding: 6px 2px; text-align: center; position: relative; font-size: 11px; background: #fafcf8; }
.day .v { display: flex; flex-direction: column; align-items: center; font-weight: 800; font-size: 13px; } .day .v .ic { width: 16px; height: 16px; color: #e3a800; }
.day.done { background: #e6f5dc; border-color: #b6dc98; } .day.today { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,200,61,.4); background: #fff8e0; }
.day .tick { position: absolute; top: -6px; right: -4px; background: var(--good); color: #fff; border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; } .day .tick .ic { width: 11px; height: 11px; stroke-width: 3; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: rgba(20,30,16,.92); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); } #toast.ok { background: #2b8a35; } #toast.bad { background: #b9423a; }

/* ---------- quiz */
.quiz { gap: 12px; }
.quiz-head { text-align: center; } .quiz-word { font-size: 32px; font-weight: 900; letter-spacing: 3px; color: var(--green-dd); }
.quiz-opts { display: flex; flex-direction: column; gap: 8px; }
.quiz-opt { text-align: left; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-size: 15px; line-height: 1.3; }
.quiz-opt:hover:not(:disabled) { border-color: var(--green); background: #f4fbec; }
.quiz-opt.right { background: #dff4d6; border-color: var(--good); } .quiz-opt.wrong { background: #fde3e0; border-color: var(--bad); }
.quiz-result { text-align: center; font-weight: 700; min-height: 20px; } .quiz-result.good { color: var(--good); } .quiz-result.bad { color: var(--bad); }

/* ---------- game */
.game { height: 100%; display: flex; flex-direction: column; padding: max(8px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom)); gap: 6px; position: relative; overflow: hidden; color: #fff; }
.game .loading { margin: auto; font-weight: 700; }
.bg0 { background: linear-gradient(#cfeccb, #5c9a55 55%, #2d5a2e); }
.bg1 { background: linear-gradient(#a9cdf0, #5f89ab 55%, #2f4e68); }
.bg2 { background: linear-gradient(#9fdcf7, #2f8fc7 55%, #144a73); }
.bg3 { background: linear-gradient(#ffc7a1, #de6262 55%, #5b2a53); }
.bg4 { background: linear-gradient(#34487f, #1d2550 55%, #0d1030); }
.bg5 { background: linear-gradient(#ffe6b0, #e4a65c 55%, #a8652c); }
.bg6 { background: linear-gradient(#eef7ff, #aacbe3 55%, #6c91b0); }
.bg7 { background: linear-gradient(#e0f7b4, #7cc242 55%, #3c7a28); }
.g-top { display: flex; align-items: center; gap: 8px; }
.g-title { flex: 1; min-width: 0; text-shadow: 0 1px 3px rgba(0,0,0,.35); } .g-level { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .g-sub { font-size: 11px; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-chips { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; } .chip-top.bonus { cursor: pointer; font-size: 12px; padding: 3px 9px; } .chip-top.bonus .num { margin-right: 3px; }
.grid-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.grid { position: relative; }
.cell { position: absolute; width: var(--cell); height: var(--cell); border-radius: 7px; background: rgba(255,255,255,.28); border: 1.5px solid rgba(255,255,255,.55); display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.cell.on { background: var(--green); border-color: #a5dd72; color: #fff; box-shadow: 0 2px 0 var(--green-dd); }
.cell .ch { font-weight: 900; font-size: calc(var(--cell) * .62); text-shadow: 0 1px 0 rgba(0,0,0,.18); }
.cell.pop { animation: pop .35s ease-out; } @keyframes pop { 0% { transform: scale(.3); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.preview { align-self: center; min-height: 38px; padding: 3px 20px; border-radius: 20px; background: var(--green); color: #fff; font-weight: 900; font-size: 22px; letter-spacing: 3px; opacity: 0; transition: opacity .1s; display: flex; align-items: center; border-bottom: 3px solid var(--green-dd); }
.preview.on { opacity: 1; }
.preview.shake { animation: shake .35s; background: var(--bad); border-color: #b9423a; opacity: 1; } @keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.wheel-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.wheel { position: relative; width: min(62vw, 300px, 36dvh); aspect-ratio: 1; flex: none; border-radius: 50%; background: rgba(255,255,255,.93); touch-action: none; user-select: none; box-shadow: 0 6px 20px rgba(0,0,0,.28), inset 0 0 0 4px rgba(255,255,255,.6); }
.wheel-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.wheel-lines polyline { fill: none; stroke: var(--green); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.wl { position: absolute; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 900; color: #2b3b28; pointer-events: none; transition: left .35s ease, top .35s ease, background .1s, color .1s; }
.wl.sel { background: var(--green); color: #fff; }
.wheel-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 22%; aspect-ratio: 1; border-radius: 50%; border: 0; background: rgba(0,0,0,.07); color: #5a6c56; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2; }
.wheel-center .ic { width: 52%; height: 52%; }
.hint-btn { width: 54px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: rgba(0,0,0,.32); color: #fff; border-radius: 16px; padding: 8px 2px 4px; cursor: pointer; }
.hint-btn .ic { width: 26px; height: 26px; }
.hint-btn .cost { font-size: 12px; font-weight: 800; background: var(--gold); color: #5b3d00; border-radius: 99px; padding: 0 7px; }
.hint-btn.poor { opacity: .6; } .hint-btn.poor .cost { background: #e9c9c5; color: #7a2a24; }
.float { position: absolute; left: 50%; top: 42%; transform: translateX(-50%); font-weight: 900; font-size: 30px; pointer-events: none; z-index: 20; animation: floatup 1.2s ease-out forwards; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
.float.gain { color: #ffe066; } .float.loss { color: #ff9a92; } @keyframes floatup { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -70px); } }
.confetti { position: absolute; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; } .confetti i { position: absolute; top: -12px; width: 9px; height: 14px; animation: fall 2.2s ease-in forwards; } @keyframes fall { to { top: 105%; transform: rotate(720deg); } }

/* ---------- flashcards */
.flash { min-height: 100%; }
.fc { perspective: 1000px; height: min(52dvh, 360px); cursor: pointer; margin: 6px 0; }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.fc.flipped .fc-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #fff; border: 2px solid var(--line); border-radius: 20px; display: flex; align-items: center; justify-content: center; padding: 20px; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.face.back { transform: rotateY(180deg); background: #f4fbec; border-color: #bfe0a5; }
.face-text { font-size: 34px; font-weight: 800; text-align: center; overflow-wrap: anywhere; } .face-text.long { font-size: 20px; font-weight: 600; line-height: 1.35; }
.fc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .fc-actions .btn { padding: 14px 8px; }

@media (min-width: 700px) { #shell { margin: 12px auto; height: calc(100dvh - 24px); border-radius: 24px; } }
@media (max-height: 640px) { .wheel { width: min(60vw, 240px, 34dvh); } .hint-btn { width: 46px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---- v2: level 6, report flag, offline chip, wrapping definitions ---- */
.lvl.l6 { background: #c2418a; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.icon-btn.flag { width: 30px; height: 30px; color: var(--muted); border-color: transparent; background: transparent; }
.icon-btn.flag:hover { color: #c0392b; background: #fff; border-color: var(--line); }
.icon-btn.flag svg { width: 16px; height: 16px; }
.netchip { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 60; display: inline-flex; align-items: center; gap: 6px; background: #3d4a3a; color: #fff; border: 0; border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 700; box-shadow: 0 2px 10px rgba(0,0,0,.25); cursor: pointer; max-width: 92vw; }
.netchip svg { width: 14px; height: 14px; }
.netchip.hidden { display: none; }
.quiz .row.end { margin-top: 6px; }
.face-text { white-space: pre-line; }
