.hidden { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; background: radial-gradient(circle at top, #151c2c 0%, #0b0e14 60%); color: #f3f4f6; min-height: 100dvh; display: flex; justify-content: center; }
.study-shell { width: min(940px, 94vw); padding: 24px 0 48px; }
.study-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.study-header h1 { margin: 0; font-size: 1.55rem; }
.study-sub { margin: 4px 0 0; font-size: 0.86rem; color: #94a3b8; }
.study-links { display: flex; flex-wrap: wrap; gap: 8px; }
.ext-link { padding: 8px 13px; border-radius: 9px; background: #182032; border: 1px solid #2b364d; color: #7dd3fc; text-decoration: none; font-size: 0.84rem; font-weight: 600; }
.ext-link:hover { border-color: #38bdf8; background: #1e293b; }
.tab-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.tab-btn { padding: 9px 15px; border-radius: 10px; border: 1px solid #283145; background: #131824; color: #cbd5e1; font-weight: 600; cursor: pointer; }
.tab-btn.active { background: #2563eb; border-color: #3b82f6; color: #fff; }
.calc-card { width: min(340px, 100%); margin: 12px auto; background: #181b24; padding: 18px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 12px 30px rgba(0,0,0,0.45); }
.calc-display { background: #0b0d12; padding: 16px; border-radius: 10px; text-align: right; font-size: 1.85rem; margin-bottom: 12px; overflow-x: auto; font-variant-numeric: tabular-nums; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.calc-grid button { padding: 14px; font-size: 1.1rem; border: 0; border-radius: 8px; background: #242938; color: #fff; cursor: pointer; }
.calc-grid button.eq { grid-column: span 2; background: #3b82f6; }
.tool-card { background: #141925; border: 1px solid rgba(255,255,255,0.08); border-radius: 16px; padding: 20px; }
.tool-card h2 { margin: 0 0 12px; font-size: 1.2rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: #cbd5e1; }
.form-grid input { padding: 10px 12px; border-radius: 9px; border: 1px solid #2b354b; background: #0d111a; color: #fff; font-size: 0.95rem; }
.primary-btn { padding: 10px 18px; border: 0; border-radius: 10px; background: linear-gradient(135deg, #38bdf8, #2563eb); color: #fff; font-weight: 650; cursor: pointer; }
.mtg-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.stat-box { background: #0e131e; border: 1px solid #242e42; border-radius: 12px; padding: 13px; display: flex; flex-direction: column; gap: 4px; }
.stat-box span { font-size: 0.8rem; color: #94a3b8; }
.stat-box strong { font-size: 1.2rem; color: #38bdf8; }
.quiz-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.quiz-topics { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.topic-pill { padding: 7px 13px; border-radius: 999px; border: 1px solid #2b354b; background: #0f1420; color: #cbd5e1; font-size: 0.83rem; font-weight: 600; cursor: pointer; }
.topic-pill.active { background: #0284c7; border-color: #38bdf8; color: #fff; }
.quiz-list { display: flex; flex-direction: column; gap: 12px; }
.quiz-item { background: #0f141f; border: 1px solid #232c3f; border-radius: 12px; padding: 14px; }
.quiz-q { margin: 0 0 10px; font-weight: 600; font-size: 0.95rem; }
.quiz-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.quiz-opt { padding: 7px 12px; border-radius: 8px; border: 1px solid #2c364d; background: #182032; color: #f1f5f9; cursor: pointer; font-size: 0.85rem; }
.quiz-opt.correct { background: rgba(34,197,94,0.22); border-color: #22c55e; color: #4ade80; }
.quiz-opt.wrong { background: rgba(239,68,68,0.22); border-color: #ef4444; color: #f87171; }
.quiz-exp { margin: 9px 0 0; font-size: 0.82rem; color: #93c5fd; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.72); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 60; }
.modal-card { background: #181b24; padding: 22px; border-radius: 14px; border: 1px solid #2b3347; display: flex; flex-direction: column; gap: 10px; width: 290px; }
.modal-card h2 { margin: 0 0 4px; font-size: 1.2rem; }
.modal-card input, .modal-card button { padding: 10px 12px; border-radius: 8px; border: 1px solid #2e3548; background: #0f1117; color: #fff; }
.modal-card button { background: #3b82f6; border-color: #3b82f6; font-weight: 600; cursor: pointer; }
.hub { width: min(1160px, 95vw); min-height: 100dvh; padding: 22px 0 48px; }
.hub-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.hub-header h1 { margin: 0; font-size: 1.75rem; }
.hub-sub { margin: 3px 0 0; font-size: 0.86rem; color: #94a3b8; }
.storage-sub { margin: 3px 0 0; font-size: 0.78rem; color: #38bdf8; }
.hub-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search-input { width: min(230px, 80vw); padding: 9px 13px; border-radius: 10px; border: 1px solid #2a3346; background: #131824; color: #f8fafc; font-size: 0.9rem; outline: none; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.filter-pill { padding: 6px 13px; border-radius: 999px; border: 1px solid #283246; background: #121723; color: #cbd5e1; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.filter-pill.active { background: #2563eb; border-color: #38bdf8; color: #fff; }
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.game-card { background: linear-gradient(180deg, #192132 0%, #131824 100%); padding: 16px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; justify-content: space-between; gap: 12px; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.game-card h3 { margin: 0; font-size: 1.06rem; color: #f8fafc; word-break: break-word; }
.badge { padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; background: rgba(148,163,184,0.14); color: #cbd5e1; white-space: nowrap; }
.badge.cached { background: rgba(34,197,94,0.16); color: #4ade80; }
.badge.emu { background: rgba(168,85,247,0.2); color: #d8b4fe; }
.badge.ruffle { background: rgba(249,115,22,0.2); color: #fdba74; }
.card-meta { margin: 5px 0 0; font-size: 0.81rem; color: #94a3b8; }
.card-progress { display: flex; flex-direction: column; gap: 5px; }
.card-actions { display: flex; gap: 8px; }
.play-btn { flex: 1; padding: 10px 12px; border: 0; border-radius: 10px; background: linear-gradient(135deg, #38bdf8, #2563eb); color: #fff; font-weight: 650; font-size: 0.88rem; cursor: pointer; }
.play-btn:disabled { opacity: 0.6; cursor: wait; }
.del-cache-btn { padding: 10px 11px; border: 1px solid rgba(239,68,68,0.35); border-radius: 10px; background: rgba(239,68,68,0.12); color: #fca5a5; font-weight: 600; font-size: 0.8rem; cursor: pointer; }
.progress-wrap { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #0f141f; border-bottom: 1px solid rgba(255,255,255,0.06); }
.progress-track { flex: 1; height: 7px; border-radius: 999px; background: rgba(255,255,255,0.09); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, #38bdf8, #22c55e); transition: width 0.12s ease; }
.progress-text { font-size: 0.78rem; color: #cbd5e1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.player-stage { margin-top: 16px; background: #131824; border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; overflow: hidden; }
.player-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: #0f141f; border-bottom: 1px solid rgba(255,255,255,0.07); }
.player-info { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.player-status { font-size: 0.82rem; color: #94a3b8; }
.player-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.btn-secondary, .btn-danger { padding: 7px 11px; border: 0; border-radius: 8px; font-size: 0.81rem; font-weight: 600; cursor: pointer; }
.btn-secondary { background: #242d40; color: #f1f5f9; }
.btn-secondary.active { background: #0284c7; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.frame-wrapper { position: relative; width: 100%; height: 74dvh; background: #000; }
.game-frame { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.touch-overlay { position: absolute; inset: 0; pointer-events: none; display: flex; justify-content: space-between; align-items: flex-end; padding: 16px; z-index: 20; user-select: none; }
.dpad-cluster { pointer-events: auto; display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); gap: 4px; opacity: 0.72; }
.d-up { grid-column: 2; grid-row: 1; }
.d-left { grid-column: 1; grid-row: 2; }
.d-right { grid-column: 3; grid-row: 2; }
.d-down { grid-column: 2; grid-row: 3; }
.action-cluster { pointer-events: auto; display: grid; grid-template-columns: repeat(2, 52px); gap: 8px; opacity: 0.72; }
.t-btn { border: 1px solid rgba(255,255,255,0.28); border-radius: 12px; background: rgba(15,23,42,0.75); color: #f8fafc; font-weight: 700; font-size: 1rem; touch-action: none; }
.t-btn:active, .t-btn.pressed { background: rgba(56,189,248,0.65); border-color: #38bdf8; }
@media (max-width: 680px) {
  .frame-wrapper { height: 68dvh; }
  .btn-secondary, .btn-danger { padding: 7px 9px; font-size: 0.76rem; }
}
