:root {
  --ink: #1d2b53;
  --paper: #fff6d4;
  --cream: #f7e8b6;
  --orange: #ff9d3f;
  --coral: #ff6b6b;
  --teal: #2ec4b6;
  --shadow: #1d2b53;
  --touhou-red: #c91f4d;
  --touhou-purple: #9145a8;
  --touhou-blue: #0074c7;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-width: 320px; color: var(--ink); background-color: #f0d28d;
  background-image: radial-gradient(#e6be70 1px, transparent 1px); background-size: 12px 12px;
  font-family: "Courier New", Consolas, monospace; font-weight: 700;
}
button { font: inherit; color: inherit; cursor: pointer; }
.shell { width: min(1440px, calc(100% - 36px)); margin: 22px auto 28px; }
.pixel-panel { border: 3px solid var(--ink); background: var(--paper); box-shadow: 6px 6px 0 var(--shadow); }
.topbar { height: 64px; padding: 0 18px; display: flex; align-items: center; gap: 22px; background: linear-gradient(90deg, #fff6d4 0 78%, #f3e0f8 78%); }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); letter-spacing: -1px; font-size: clamp(18px, 2.3vw, 28px); }
.brand-logo { width: 40px; height: 40px; object-fit: cover; border: 2px solid var(--ink); background: #fff; box-shadow: 3px 3px 0 var(--touhou-purple); }
.brand-title { line-height: .84; }.brand-title small { display: block; margin-top: 6px; color: var(--touhou-purple); font-size: 8px; letter-spacing: .2px; }
.brand-spark { display: inline-block; color: var(--coral); margin-right: 5px; transform: rotate(10deg); }
.live-status { margin-left: auto; font-size: 12px; background: #d5f5da; border: 2px solid var(--ink); padding: 7px 9px; }
.pulse { display: inline-block; width: 8px; height: 8px; margin-right: 6px; background: #3dbb62; box-shadow: 2px 2px 0 #167638; animation: blink 1.2s steps(2) infinite; }
.counter { padding-left: 17px; border-left: 3px solid var(--ink); text-align: center; line-height: 1; }
.counter span { display: block; font-size: 20px; color: var(--coral); }
.counter small, .board-header small { display: block; margin-top: 4px; font-size: 9px; letter-spacing: .4px; }
.hero { padding: 42px 8px 28px; }
.eyebrow { color: #a14b3f; font-size: 12px; letter-spacing: 1.2px; margin: 0 0 10px; }
h1 { margin: 0; font-size: clamp(38px, 6vw, 76px); line-height: .94; letter-spacing: -4px; }
h1 em { font-style: normal; color: var(--touhou-purple); text-shadow: 3px 3px 0 var(--ink); }
.subtitle { font-size: 14px; margin: 20px 0 0; }
.game-grid { display: grid; grid-template-columns: 218px minmax(450px, 1fr) 228px; gap: 20px; align-items: start; }
.left-rail, .right-rail { padding: 16px; }
.panel-title { font-size: 13px; letter-spacing: .4px; margin-bottom: 16px; }
.panel-title span { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; background: var(--orange); border: 2px solid var(--ink); font-size: 10px; }
.selected-color { display: flex; align-items: center; gap: 10px; background: #ffe7ac; border: 2px solid var(--ink); padding: 9px; }
.selected-color > span { width: 32px; height: 32px; border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.selected-color b, .selected-color small { display: block; font-size: 11px; }
.selected-color small { opacity: .68; margin-top: 3px; font-size: 9px; }
.palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 14px; }
.swatch { aspect-ratio: 1; border: 2px solid var(--ink); box-shadow: 2px 2px 0 transparent; transition: transform .08s, box-shadow .08s; }
.swatch:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.swatch.active { outline: 3px solid var(--ink); outline-offset: 2px; transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.rule { height: 3px; margin: 20px 0; border-top: 3px dashed #d1ad68; }
.cooldown-wrap { text-align: center; }
.cooldown-ring { width: 100px; height: 100px; margin: 3px auto 10px; display: grid; align-content: center; border: 6px solid var(--teal); outline: 2px solid var(--ink); outline-offset: 3px; background: #d8fff0; }
.cooldown-ring b { font-size: 16px; color: var(--ink); }.cooldown-ring small { font-size: 9px; margin-top: 5px; }
.cooldown-wrap p { min-height: 34px; margin: 0; font-size: 10px; line-height: 1.5; }
.tip { padding: 9px; border: 2px dashed var(--ink); background: #fff0bd; font-size: 10px; line-height: 1.55; }.tip b { color: #a14b3f; }
.board-panel { overflow: hidden; }.board-header, .board-footer { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: #ffe6a1; }
.board-header { border-bottom: 3px solid var(--ink); font-size: 12px; }.board-header > div:first-child { display: flex; align-items: center; gap: 7px; }.board-header small { margin: 0 0 0 4px; opacity: .65; }.board-dot { width: 10px; height: 10px; background: var(--coral); border: 2px solid var(--ink); }.coords { font-size: 10px; opacity: .75; }.coords b { font-size: 12px; }
.viewport { position: relative; height: min(56vw, 610px); min-height: 360px; overflow: hidden; background: #1d2b53; cursor: crosshair; touch-action: none; }
canvas { position: absolute; left: 50%; top: 50%; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; transform: translate(-50%, -50%); transform-origin: center; user-select: none; }
.cursor-cell { position: absolute; display: none; width: 12px; height: 12px; pointer-events: none; border: 2px solid #fff6d4; outline: 1px solid var(--ink); mix-blend-mode: difference; }
.pixel-toast { position: absolute; left: 50%; top: 45%; display: none; transform: translate(-50%, -50%); padding: 9px 12px; color: var(--ink); background: #d8fff0; border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font-size: 12px; white-space: nowrap; pointer-events: none; }
.pixel-toast.show { display: block; animation: pop .7s steps(3); }
.board-footer { min-height: 51px; gap: 7px; border-top: 3px solid var(--ink); font-size: 11px; }.icon-button { width: 25px; height: 25px; padding: 0; border: 2px solid var(--ink); background: var(--paper); font-size: 18px; line-height: 1; }.icon-button:hover,.text-button:hover { background: var(--orange); }.drag-hint { margin-left: auto; opacity: .62; font-size: 9px; }.text-button { padding: 5px 7px; border: 2px solid var(--ink); background: transparent; font-size: 9px; }
.activity-feed { list-style: none; height: 278px; padding: 0; margin: 0; overflow: hidden; }.activity-feed li { position: relative; min-height: 48px; padding: 0 0 11px 28px; margin-bottom: 8px; border-bottom: 2px dotted #d1ad68; font-size: 10px; line-height: 1.45; }.activity-feed i { position: absolute; left: 0; top: 1px; width: 18px; height: 18px; border: 2px solid var(--ink); }.activity-feed b { color: #a14b3f; }.activity-feed small { display: block; margin-top: 2px; opacity: .6; font-size: 9px; }.activity-feed .empty-feed { padding-left: 0; padding-top: 12px; text-align: center; border: 0; opacity: .65; }
.stats { display: grid; grid-template-columns: 1fr 1fr; text-align: center; }.stats div + div { border-left: 2px solid var(--ink); }.stats b,.stats small { display: block; }.stats b { color: var(--coral); font-size: 17px; }.stats small { margin-top: 4px; font-size: 9px; }.primary-button { width: 100%; margin-top: 19px; padding: 10px 7px; border: 3px solid var(--ink); background: var(--orange); box-shadow: 3px 3px 0 var(--ink); font-size: 11px; }.primary-button:active { transform: translate(3px, 3px); box-shadow: none; }
footer { text-align: center; margin-top: 33px; font-size: 10px; opacity: .72; letter-spacing: 1px; }
@keyframes blink { 50% { opacity: .35; } } @keyframes pop { 0% { transform: translate(-50%, -30%) scale(.6); } 60% { transform: translate(-50%, -55%) scale(1.08); } 100% { transform: translate(-50%, -50%) scale(1); } }
@media (max-width: 980px) { .game-grid { grid-template-columns: 190px minmax(360px, 1fr); }.right-rail { grid-column: 1 / -1; }.right-rail .activity-feed { height: 110px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }.right-rail .activity-feed li { margin: 0; }.right-rail .stats,.right-rail .primary-button { display: none; } }
@media (max-width: 680px) { .shell { width: min(100% - 20px, 560px); margin-top: 10px; }.topbar { height: 56px; padding: 0 10px; gap: 9px; }.brand-logo { width: 34px; height: 34px; }.brand-title small { font-size: 7px; }.live-status { display: none; }.counter { margin-left: auto; }.hero { padding: 27px 3px 22px; } h1 { letter-spacing: -2.5px; }.game-grid { display: flex; flex-direction: column; gap: 14px; }.board-panel { order: -1; width: 100%; }.left-rail,.right-rail { width: 100%; }.left-rail { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }.left-rail .panel-title:nth-of-type(2),.left-rail .cooldown-wrap,.left-rail .tip,.left-rail .rule { display: none; }.left-rail .panel-title { margin: 0; }.left-rail .selected-color { align-self: center; }.palette { margin: 0; }.viewport { height: 64vw; min-height: 250px; }.drag-hint { display: none; }.right-rail .activity-feed { grid-template-columns: 1fr 1fr; } }

.account-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 10px; }.account-controls[hidden] { display: none; }.admin-link,.logout-button { border: 2px solid var(--ink); background: var(--paper); padding: 5px 7px; color: var(--ink); font: inherit; text-decoration: none; }.logout-button:hover,.admin-link:hover { background: var(--orange); }
.auth-gate { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(29, 43, 83, .78); }.auth-gate[hidden] { display: none; }.auth-card { width: min(100%, 420px); padding: 26px; }.auth-card h2 { margin: 0; font-size: 30px; letter-spacing: -2px; }.auth-copy { font-size: 11px; line-height: 1.6; }.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 20px 0 14px; border: 2px solid var(--ink); }.auth-tab { border: 0; border-right: 2px solid var(--ink); padding: 9px 5px; background: #ffe7ac; font: inherit; font-size: 11px; }.auth-tab:last-child { border-right: 0; }.auth-tab.active { background: var(--orange); }.auth-form { display: grid; gap: 11px; }.auth-form[hidden] { display: none; }.auth-form label { display: grid; gap: 5px; font-size: 11px; }.auth-form input { min-width: 0; border: 2px solid var(--ink); padding: 9px; background: #fffbed; color: var(--ink); font: inherit; font-size: 12px; }.auth-form .primary-button { margin-top: 5px; }.auth-message { min-height: 18px; margin: 13px 0 0; color: #a14b3f; font-size: 10px; line-height: 1.5; }
.admin-shell { max-width: 1180px; }.admin-hero { padding-bottom: 30px; }.admin-grid { display: grid; grid-template-columns: minmax(280px, .72fr) minmax(0, 1.8fr); gap: 20px; }.admin-create,.admin-list { padding: 18px; }.invite-form { display: grid; gap: 13px; }.invite-form label { display: grid; gap: 6px; font-size: 11px; }.invite-form input { min-width: 0; padding: 9px; border: 2px solid var(--ink); background: #fffbed; font: inherit; }.invite-form .primary-button { margin: 4px 3px 4px 0; }.latest-codes { margin-top: 18px; padding: 12px; border: 2px dashed var(--ink); background: #d8fff0; font-size: 10px; }.latest-codes b { display: block; margin-bottom: 8px; }.latest-codes code { display: inline-block; margin: 3px; padding: 4px; border: 1px solid var(--ink); background: var(--paper); user-select: all; }.admin-list-header { display: flex; justify-content: space-between; align-items: start; }.table-wrap { overflow-x: auto; border: 2px solid var(--ink); }.table-wrap table { width: 100%; min-width: 620px; border-collapse: collapse; background: #fffbed; font-size: 10px; }.table-wrap th { background: #ffe7ac; }.table-wrap th,.table-wrap td { padding: 10px; text-align: left; border-right: 1px solid #d1ad68; border-bottom: 1px solid #d1ad68; }.table-wrap code { padding: 3px; background: #d8fff0; }.empty-cell { text-align: center !important; opacity: .65; }.admin-list .panel-title { margin-bottom: 14px; }
@media (max-width: 760px) { .account-controls { gap: 4px; }.account-controls #currentUser { display:none; }.admin-grid { grid-template-columns: 1fr; }.admin-hero { padding-top: 28px; } }
