:root {
  --bg: #1b2a3a; --panel: rgba(16, 24, 34, .78); --ink: #f3f6fa; --sub: #9fb0c3; --accent: #6cbb3c;
  --radius: 14px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

.top { position: fixed; top: calc(8px + var(--safe-t)); left: 10px; right: 10px; display: flex; align-items: center; gap: 10px; z-index: 5; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; background: var(--panel); padding: 8px 12px; border-radius: var(--radius); backdrop-filter: blur(10px); }
.cube { width: 16px; height: 16px; background: linear-gradient(135deg, #7ed957 50%, #6cbb3c 50%); border-radius: 4px; box-shadow: inset -3px -3px 0 #4e8f2a; }
.stat { font-size: 13px; color: var(--sub); background: var(--panel); padding: 8px 10px; border-radius: var(--radius); }
.stat span { color: var(--ink); font-weight: 700; }
.actions { margin-left: auto; display: flex; gap: 6px; }
.actions button { width: 40px; height: 40px; border-radius: 12px; background: var(--panel); font-size: 18px; backdrop-filter: blur(10px); }
.actions button:disabled { opacity: .35; cursor: default; }

.mode { position: fixed; left: 10px; top: calc(60px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.mode button { padding: 10px 14px; border-radius: 12px; background: var(--panel); font-weight: 700; font-size: 14px; backdrop-filter: blur(10px); border: 2px solid transparent; }
.mode button.on { border-color: var(--accent); }
.mode button[data-mode="remove"].on { border-color: #e03b3b; }
.mode button[data-mode="paint"].on { border-color: #f2d335; }

.palette { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 10px calc(10px + var(--safe-b)); display: flex; gap: 8px; overflow-x: auto; z-index: 5;
  background: linear-gradient(transparent, rgba(10, 16, 24, .85) 40%); scrollbar-width: none; }
.palette::-webkit-scrollbar { display: none; }
.palette button { flex: 0 0 auto; width: 56px; height: 64px; border-radius: 12px; background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; color: var(--sub); border: 2px solid transparent; }
.palette button.on { border-color: #fff; color: var(--ink); }
.palette .sw { width: 28px; height: 28px; border-radius: 6px; box-shadow: inset -4px -4px 0 rgba(0, 0, 0, .25), inset 3px 3px 0 rgba(255, 255, 255, .25); }

.hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); font-size: 12px; color: var(--sub); background: var(--panel); padding: 6px 12px; border-radius: 999px; z-index: 5; white-space: nowrap; transition: opacity .4s; }
.hint.hide { opacity: 0; pointer-events: none; }

dialog { border: 0; padding: 0; background: transparent; max-width: none; width: 100%; max-height: none; }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.sheet-body { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(480px, 100%); background: #111a26; color: var(--ink); border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; }
.sheet-body h2 { margin: 0 0 4px; font-size: 18px; }
.row { display: flex; gap: 8px; }
.row button, .sheet-body > button { flex: 1; padding: 12px; border-radius: 12px; background: #223247; font-weight: 700; }
.row button.danger { background: #4a1f1f; color: #ffb3b3; }
.sheet-body .ghost { background: transparent; color: var(--sub); }
.sheet-body label { font-size: 13px; color: var(--sub); display: flex; flex-direction: column; gap: 6px; }
textarea { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: #0b121b; color: var(--ink); border: 1px solid #2b3a50; border-radius: 10px; padding: 8px; resize: none; word-break: break-all; }
.small { font-size: 12px; color: var(--sub); margin: 0; }
.keys { display: none; }
@media (hover: hover) and (pointer: fine) { .keys { display: block; } .hint { display: none; } }

.toast { position: fixed; top: calc(60px + var(--safe-t)); left: 50%; transform: translateX(-50%) translateY(-10px); background: #fff; color: #111; font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 999px; opacity: 0; transition: .25s; z-index: 9; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

body.og .top, body.og .mode, body.og .palette, body.og .hint, body.og .toast { display: none; }
.home { color: var(--sub); text-decoration: none; text-align: center; }
.room-only { display: none !important; }
body.room .room-only { display: block !important; }
body.room .stat.room-only { display: inline-block !important; }
body.room .solo-only { display: none !important; }
.coop { padding: 12px; border-radius: 12px; background: #2f5d1f; color: #dfffd0; font-weight: 700; }
.coop:disabled { opacity: .6; }
@media (max-width: 480px) {
  .brand { padding: 8px 10px; }
  .brand span + * { display: none; }
  .brand { font-size: 0; gap: 0; }
  .stat { white-space: nowrap; font-size: 12px; padding: 8px 8px; }
  .actions button { width: 36px; height: 36px; }
}
