* { box-sizing: border-box; }
:root { --accent: #f4a261; --red: #e76f51; --ink: #26313d; --muted: #6b7785; --line: #e3e7ec; --gr-accent: #e76f51; }
html, body { margin: 0; color: var(--ink); font-family: Pretendard, "Noto Sans KR", system-ui, "Malgun Gothic", sans-serif; }
body { min-height: 100vh; background: #fdf6ee; -webkit-user-select: none; user-select: none; }
button { font: inherit; cursor: pointer; color: inherit; }
[hidden] { display: none !important; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.bar a { color: var(--ink); text-decoration: none; font-weight: 800; white-space: nowrap; }
.bar-actions { display: flex; gap: 6px; }
.bar button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px 12px; white-space: nowrap; }

.shell { max-width: 1000px; margin: 0 auto; padding: 12px 16px 32px; }
.hud { display: flex; align-items: center; gap: 12px; font-weight: 900; }
.pill { padding: 5px 12px; border-radius: 999px; background: var(--red); color: #fff; font-variant-numeric: tabular-nums; }
.time { font-variant-numeric: tabular-nums; }
.time.low { color: #d62828; }
.score { margin-left: auto; font-size: 18px; font-variant-numeric: tabular-nums; }
.meter-track { height: 8px; margin: 8px 0; border-radius: 99px; background: #f1e3d3; overflow: hidden; }
.meter-track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--red)); }

.stage { border-radius: 16px; overflow: hidden; border: 3px solid #fff; box-shadow: 0 12px 30px #26313d22; }
.stage canvas { display: block; width: 100%; aspect-ratio: 960 / 600; touch-action: none; cursor: crosshair; }

.tool-now { margin: 10px 0 6px; text-align: center; font-weight: 900; }
.group-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.group-tab { flex: 0 0 auto; border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font-weight: 800; white-space: nowrap; }
.group-tab[aria-selected="true"] { border-color: var(--red); background: var(--red); color: #fff; }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.tool { position: relative; }
.tool .ico::after { content: attr(data-key); position: absolute; left: 7px; top: 4px; font: 700 11px system-ui; color: #a0a8b3; }
.tool { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border: 2px solid var(--line); border-radius: 14px; background: #fff; }
.tool .ico { font-size: 28px; line-height: 1; }
.tool .count { font-size: 13px; color: var(--muted); font-weight: 800; }
.tool[aria-pressed="true"] { border-color: var(--red); background: #fff1ea; }
.tool:disabled { opacity: .35; cursor: default; }
.actions { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.actions button { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 16px; font-weight: 800; }
.help { text-align: center; color: var(--muted); font-size: 14px; line-height: 1.6; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(30, 20, 10, .45); z-index: 20; }
.overlay-card { width: 100%; max-width: 460px; max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px 20px; border-radius: 24px; background: #fff; text-align: center; box-shadow: 0 20px 50px #0004; }
.ov-emoji { font-size: 56px; }
.overlay-card h1 { margin: 4px 0 8px; font-size: 28px; }
.ov-text { color: var(--muted); line-height: 1.6; white-space: pre-line; }
.ov-best { font-weight: 800; }
.ov-best:empty { display: none; }
.primary, .ghost { display: block; width: 100%; border-radius: 14px; padding: 13px; font-weight: 900; margin-top: 8px; }
.primary { border: 0; color: #fff; font-size: 18px; background: linear-gradient(135deg, var(--accent), var(--red)); }
.ghost { border: 1px solid var(--line); background: #fff; font-size: 16px; }
.primary small, .ghost small { display: block; font-size: 12px; font-weight: 700; opacity: .85; }

.school-title { margin: 12px 0 6px; font-weight: 900; }
.school-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.school-btn { display: grid; justify-items: center; gap: 2px; padding: 8px 2px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-size: 12px; }
.school-btn span { font-size: 24px; line-height: 1.1; }
.school-btn[aria-pressed="true"] { border-color: var(--red); background: #fff1ea; }

@media (max-width: 480px) { .tools { grid-template-columns: repeat(3, 1fr); } .school-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 480px) { .tool b { font-size: 13px; } .tool .ico { font-size: 24px; } }
