:root {
  --ink: #14121F;
  --bg: #0E0C16;
  --panel: #17142A;
  --line: #2E2A45;
  --chip: #262336;
  --violet: #7B4DFF;
  --violet-soft: #C9B8FF;
  --yellow: #FFD23F;
  --green: #18B07A;
  --green-soft: #5BE3A8;
  --red: #FF5A6E;
  --text: #FFFFFF;
  --muted: #A3A1B3;
  --muted2: #8E8CA0;
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #08070C; color: var(--text); font-family: 'Inter', system-ui, -apple-system, sans-serif; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* Phone frame: full screen on mobile, centered column on desktop */
#app { position: relative; max-width: 440px; height: 100dvh; margin: 0 auto; background: var(--bg); overflow: hidden; }
@media (min-width: 500px) { #app { height: min(100dvh, 920px); margin-top: max(0px, calc((100dvh - 920px) / 2)); border-radius: 28px; box-shadow: 0 0 0 1px #222, 0 30px 80px rgba(123,77,255,.2); } }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; animation: fade .18s ease; }
.scroll { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 110px; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.disp { font-weight: 900; letter-spacing: -0.03em; }
h1.disp { font-size: 28px; line-height: 1.15; margin: 0 0 16px; }
.muted { color: var(--muted); } .muted2 { color: var(--muted2); }
.small { font-size: 13px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 50px; padding: 0 18px; border-radius: 14px; font-weight: 900; font-size: 16px; background: var(--violet); color: #fff; transition: transform .08s; }
.btn:active { transform: scale(.97); }
.btn.y { background: var(--yellow); color: var(--ink); }
.btn.w { background: #fff; color: var(--ink); }
.btn.g { background: var(--chip); color: #D8D6E4; }
.btn.ok { background: var(--green); }
.btn.bad { background: #3A1E28; color: #FF8FA0; }
.btn.round { border-radius: 999px; }
.btn.full { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.footer { position: absolute; left: 14px; right: 14px; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 8px; z-index: 6; }
.footer .btn { flex: 1; }

/* Cards, chips */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tag { display: inline-block; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--chip); color: #C9C7D6; }
.tag.y { background: var(--yellow); color: var(--ink); }
.tag.dy { background: #3A2E0E; color: var(--yellow); }
.badge { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; background: var(--violet); margin: 4px 4px 0 0; }
.badge.y { background: var(--yellow); color: var(--ink); }
.badge.r { background: var(--red); }
.seg { display: grid; gap: 5px; background: var(--bg); border-radius: 14px; padding: 5px; }
.seg button { padding: 12px 2px; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: 14px; }
.seg button.on { background: var(--violet); color: #fff; font-weight: 900; }
.row { display: flex; gap: 10px; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.logo { width: 32px; height: 32px; flex: 0 0 32px; }
.brand { font-weight: 900; font-size: 18px; letter-spacing: -0.02em; }
.brand span { color: var(--yellow); }

.topbar { position: absolute; left: 14px; right: 14px; top: 12px; display: flex; gap: 10px; align-items: center; z-index: 5; }
.x { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 999px; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; }
.prog { display: flex; gap: 5px; flex: 1; }
.prog i { flex: 1; height: 5px; border-radius: 9px; background: rgba(255,255,255,.25); display: block; }
.prog i.on { background: var(--yellow); }

/* Video area */
.video { position: absolute; inset: 0; background: #111; }
.video svg, .video iframe { width: 100%; height: 100%; display: block; border: 0; }
.video.dim::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.ost { position: absolute; left: 22px; right: 22px; top: 72px; text-align: center; font-weight: 700; font-size: 25px; line-height: 1.22; text-shadow: 0 0 2px rgba(0,0,0,.9), 0 0 8px rgba(0,0,0,.65), 0 2px 4px rgba(0,0,0,.6); z-index: 2; }
button.ost { color: #fff; }
.ost .hl { background: var(--violet); border-radius: 8px; padding: 0 6px; box-shadow: 0 0 0 3px #fff; text-shadow: none; }
.ost .dim { opacity: .45; }
.rail { position: absolute; right: 12px; bottom: 170px; display: flex; flex-direction: column; gap: 14px; align-items: center; font-size: 12px; font-weight: 800; text-shadow: 0 1px 2px #000; z-index: 2; text-align: center; }
.meta { position: absolute; left: 14px; right: 80px; bottom: 96px; text-shadow: 0 1px 2px #000; z-index: 2; }

/* Stickers */
.stickers { position: absolute; inset: 70px 0 120px; z-index: 3; }
.st { position: absolute; display: inline-block; padding: 10px 14px; border-radius: 14px; font-weight: 900; font-size: 18px; border: 3px solid #fff; box-shadow: 0 6px 0 rgba(0,0,0,.35); text-align: left; transition: transform .15s; }
.st small { display: block; font-size: 12px; font-weight: 700; opacity: .85; }
.st.white { background: #fff; color: var(--ink); border-color: var(--ink); }
.st.yellow { background: var(--yellow); color: var(--ink); }
.st.violet { background: var(--violet); color: #fff; }
.st.rare { background: var(--yellow); color: var(--ink); }
.st.locked { background: var(--chip); color: var(--muted2); border-style: dashed; border-color: var(--muted2); }
.st.done::after { content: '✓'; position: absolute; top: -10px; right: -10px; width: 24px; height: 24px; border-radius: 999px; background: var(--green); color: #fff; font-size: 14px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }

/* Bottom sheet and overlays */
.overlay { position: absolute; inset: 0; z-index: 20; background: rgba(8,7,12,.6); animation: fade .15s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88%; overflow-y: auto; background: var(--panel); border-top-left-radius: 24px; border-top-right-radius: 24px; border-top: 1px solid var(--line); padding: 10px 16px calc(90px + env(safe-area-inset-bottom)); }
.grab { width: 40px; height: 5px; border-radius: 9px; background: #3A3654; margin: 0 auto 12px; }

/* Chat bubbles */
.vline { display: flex; gap: 8px; align-items: flex-start; }
.msg { padding: 11px 14px; border-radius: 18px; font-size: 15px; line-height: 1.45; background: var(--chip); border-bottom-left-radius: 6px; }
.msgs { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.formula { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-weight: 900; font-size: 15px; margin: 4px 0; }
.formula span { padding: 6px 10px; border-radius: 10px; background: #fff; color: var(--ink); }
.formula span:nth-child(even) { background: var(--violet); color: #fff; }

/* Big word card */
.wcard { border-radius: 26px; background: var(--violet); border: 4px solid #fff; padding: 22px; box-shadow: 0 10px 0 rgba(0,0,0,.4); }
.wcard.rare { background: var(--yellow); color: var(--ink); }
.wcard .en { font-size: 38px; line-height: 1.02; margin: 12px 0 6px; }
.wcard .tr { background: #fff; color: var(--ink); border-radius: 16px; padding: 14px; margin-top: 14px; }

.word { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; }
.word .r { color: var(--muted); font-size: 13px; margin-top: 2px; }
.lvl { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.lvl.beg { background: var(--yellow); color: var(--ink); }
.lvl.pro { background: var(--violet); }

/* Options */
.opt { width: 100%; text-align: left; justify-content: flex-start; min-height: 58px; font-size: 17px; }

/* Comments */
.cm { display: flex; gap: 10px; padding: 12px; border-radius: 14px; width: 100%; text-align: left; }
.cm + .cm { margin-top: 4px; }
.cm:active { background: var(--panel); }
.av { width: 36px; height: 36px; border-radius: 999px; flex: 0 0 36px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: #fff; }
.fire { color: var(--yellow); font-size: 11.5px; font-weight: 900; letter-spacing: .04em; margin-top: 3px; }
.tabs { display: flex; gap: 5px; background: var(--bg); border-radius: 12px; padding: 4px; margin: 12px 0; }
.tabs button { flex: 1; padding: 9px 2px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--muted); }
.tabs button.on { background: var(--yellow); color: var(--ink); font-weight: 900; }
.reply { margin: 12px 0 0 30px; padding: 12px; border-radius: 14px; background: #221B3D; border: 2px solid var(--violet); display: flex; gap: 10px; align-items: center; }
.mistake { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.mistake div { border-radius: 12px; padding: 10px; font-size: 12px; font-weight: 800; }
.mistake b { display: block; font-size: 15px; margin-top: 2px; color: #fff; }

/* Game */
.slots { border: 2px dashed rgba(255,255,255,.5); border-radius: 18px; padding: 14px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 120px; }
.piece { padding: 10px 13px; border-radius: 12px; font-weight: 900; font-size: 16px; border: 3px solid #fff; background: var(--violet); box-shadow: 0 5px 0 rgba(0,0,0,.35); }
.piece.placed { background: #fff; color: var(--ink); border-color: var(--ink); }
.slot { width: 120px; height: 46px; border-radius: 12px; border: 2px dashed rgba(255,255,255,.35); }

/* Nav */
.nav { position: absolute; left: 0; right: 0; bottom: 0; height: calc(66px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--chip); display: grid; grid-template-columns: repeat(3, 1fr); z-index: 8; }
.nav button { font-size: 12px; font-weight: 700; color: var(--muted2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.nav button.on { color: var(--yellow); }

/* Toast */
.toast { position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%); background: #fff; color: var(--ink); font-weight: 800; font-size: 14px; padding: 10px 16px; border-radius: 999px; z-index: 50; white-space: nowrap; animation: fade .2s; }

/* Wave */
.wave { display: flex; align-items: center; gap: 3px; height: 22px; }
.wave i { width: 3px; border-radius: 3px; background: var(--yellow); display: block; }
.play { width: 34px; height: 34px; border-radius: 999px; background: #fff; display: flex; align-items: center; justify-content: center; flex: 0 0 34px; }

/* Share card */
.share { width: 280px; height: 500px; border-radius: 26px; overflow: hidden; position: relative; border: 5px solid #fff; transform: rotate(-3deg); box-shadow: 0 14px 0 rgba(0,0,0,.4); margin: 10px auto; }
