:root {
  --mint: #c9efc8;
  --mint-2: #b8e7b6;
  --mint-3: #95d792;
  --deep-green: #2e653c;
  --ink: #111311;
  --ink-2: #262b27;
  --paper: #f4f3e9;
  --paper-2: #e9eadc;
  --line: rgba(17, 19, 17, .14);
  --panel: rgba(247, 248, 239, .94);
  --shadow: 0 22px 60px rgba(25, 51, 30, .16);
  --pixel: "Courier New", Courier, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--mint); color: var(--ink); }
body { font-family: Arial, Helvetica, sans-serif; overflow-x: hidden; }
button, a { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.loader {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-content: center; gap: 22px;
  background: var(--mint); text-align: center; transition: opacity .45s ease, visibility .45s ease;
}
.loader.out { opacity: 0; visibility: hidden; }
.loader-mark { display: flex; align-items: center; justify-content: center; font-weight: 950; font-size: clamp(58px, 9vw, 110px); letter-spacing: -9px; }
.loader-mark span { display: inline-grid; place-items: center; width: .72em; height: .9em; }
.loader-mark .door-zero { position: relative; width: .58em; height: .72em; margin: 0 .03em; border: .16em solid var(--ink); border-bottom-width: .11em; }
.loader-mark .door-zero::after { content: ""; position: absolute; inset: 10% 12% 0 46%; background: linear-gradient(135deg, #efffec, #4b7754); clip-path: polygon(0 0,100% 12%,100% 100%,0 76%); }
.loader p { margin: 0; font-family: var(--pixel); font-size: 12px; letter-spacing: .22em; text-transform: uppercase; }
.dots { display: inline-block; width: 24px; animation: blink 1.2s steps(4,end) infinite; overflow: hidden; vertical-align: bottom; }
@keyframes blink { 0% { width: 0; } 100% { width: 24px; } }

.app-shell { min-height: 100vh; }
.topbar {
  height: 74px; display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 0 22px;
  border-bottom: 1px solid rgba(17,19,17,.16); background: rgba(201,239,200,.9); backdrop-filter: blur(16px);
  position: sticky; top: 0; z-index: 60;
}
.brand { display: inline-flex; align-items: center; gap: 10px; width: max-content; font-weight: 950; letter-spacing: -.035em; font-size: 20px; }
.brand img { width: 40px; height: 40px; object-fit: cover; border: 1px solid rgba(17,19,17,.18); image-rendering: auto; }
.top-actions { justify-self: end; display: flex; gap: 8px; }
.ghost-btn, .icon-btn { border: 1px solid rgba(17,19,17,.22); background: rgba(255,255,255,.18); cursor: pointer; }
.ghost-btn { padding: 10px 12px; font-family: var(--pixel); font-size: 10px; letter-spacing: .08em; }
.ghost-btn:hover { background: var(--ink); color: var(--mint); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: calc(100vh - 74px); }
.room-wrap { padding: 18px; min-width: 0; }
.room-chrome { min-height: 52px; display: flex; justify-content: space-between; align-items: center; font-family: var(--pixel); font-size: 9px; letter-spacing: .14em; padding: 0 4px 8px; gap: 16px; position: relative; z-index: 8; }
.room-label { display: flex; gap: 14px; align-items: center; flex: 0 0 auto; }
.room-id { font-weight: 800; }
.room-meta { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: visible; }
.clock-readout { font-weight: 900; flex: 0 0 auto; }
.token-strip {
  display: inline-flex; align-items: stretch; min-height: 38px; overflow: hidden;
  border: 1px solid rgba(17,19,17,.72); background: rgba(244,243,233,.94);
  box-shadow: 5px 5px 0 rgba(17,19,17,.13), 0 12px 28px rgba(27,69,35,.10);
  transform: translateY(6px);
}
.token-ticker, .token-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 13px; border: 0; border-right: 1px solid rgba(17,19,17,.22);
  background: transparent; color: var(--ink); font-family: var(--pixel); font-size: 9px;
  line-height: 1; letter-spacing: .07em; white-space: nowrap;
}
.token-ticker { background: var(--ink); color: var(--mint); font-weight: 900; font-size: 14px; padding-left: 16px; padding-right: 16px; }
.token-chip:last-child { border-right: 0; }
.token-chip-label { opacity: .52; font-size: .88em; }
button.token-chip { cursor: pointer; }
button.token-chip:disabled { cursor: default; opacity: .62; }
.token-pons { cursor: pointer; font-weight: 800; }
.token-pons:not(.disabled):hover, button.token-ca:not(:disabled):hover { background: var(--ink); color: var(--mint); }
.token-pons.disabled { opacity: .52; cursor: default; pointer-events: none; }
.canvas-frame { position: relative; width: 100%; background: #e8f3df; border: 1px solid rgba(17,19,17,.28); box-shadow: var(--shadow); overflow: hidden; }
#roomCanvas { display: block; width: 100%; height: auto; aspect-ratio: 16/9; image-rendering: pixelated; cursor: crosshair; touch-action: none; background: #d8efcf; }
.drop-hint, .toast, .spectator-badge { position: absolute; z-index: 5; font-family: var(--pixel); font-size: 10px; letter-spacing: .1em; box-shadow: 4px 4px 0 rgba(17,19,17,.18); }
.drop-hint { left: 50%; bottom: 18px; transform: translateX(-50%); padding: 10px 12px; background: var(--ink); color: var(--mint); }
.toast { left: 18px; bottom: 18px; max-width: min(430px, calc(100% - 36px)); padding: 12px 14px; background: var(--paper); border: 1px solid var(--ink); }
.toast.danger { background: var(--ink); color: var(--mint); }
.spectator-badge { right: 14px; top: 14px; padding: 9px 10px; display: flex; align-items: center; gap: 8px; background: rgba(244,243,233,.9); border: 1px solid rgba(17,19,17,.55); }
.eye { width: 11px; height: 7px; border: 2px solid currentColor; border-radius: 50%; position: relative; }
.eye::after { content: ""; position: absolute; width: 3px; height: 3px; background: currentColor; left: 2px; top: 0; }
.mobile-hint { display: none; padding: 12px 0 0; font-family: var(--pixel); font-size: 9px; letter-spacing: .08em; text-align: center; }

.panel { border-left: 1px solid rgba(17,19,17,.16); background: var(--panel); display: flex; flex-direction: column; min-height: calc(100vh - 74px); }
.panel-scroll { padding: 26px 22px 18px; display: grid; gap: 16px; }
.eyebrow, .small-label { font-family: var(--pixel); text-transform: uppercase; letter-spacing: .12em; font-size: 9px; }
.intro-card { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.intro-card .eyebrow { margin: 0 0 12px; opacity: .62; }
.intro-card h1 { margin: 0 0 12px; font-size: 42px; line-height: .94; letter-spacing: -.055em; }
.intro-card h1 em { color: var(--deep-green); font-style: normal; }
.intro-card p:last-child { margin: 0; line-height: 1.5; font-size: 13px; color: rgba(17,19,17,.72); }
.move-card { display: flex; align-items: center; gap: 12px; background: var(--mint); border: 1px solid rgba(17,19,17,.22); padding: 12px; }
.move-icon { width: 38px; height: 38px; display: grid; place-items: center; background: var(--ink); color: var(--mint); font-size: 20px; }
.move-card strong { display: block; margin-top: 4px; font-family: var(--pixel); font-size: 12px; letter-spacing: .08em; }
.move-card.used { background: #dadfd5; color: rgba(17,19,17,.65); }
.object-card, .rule-card { border: 1px solid var(--line); background: rgba(255,255,255,.34); padding: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.count-chip { font-family: var(--pixel); font-size: 9px; background: var(--ink); color: var(--mint); padding: 4px 6px; }
.object-card h2 { margin: 12px 0 6px; font-size: 20px; letter-spacing: -.03em; }
.object-card p, .rule-card p { margin: 0; line-height: 1.45; font-size: 12px; color: rgba(17,19,17,.7); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); }
.stat-grid > div { min-height: 74px; padding: 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat-grid > div:nth-child(2n) { border-right: 0; }
.stat-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
.stat-grid strong { display: block; margin-top: 9px; font-family: var(--pixel); font-size: 16px; }
.rule-card strong { color: var(--deep-green); }
.rule-card.muted { opacity: .75; }
.panel-footer { margin-top: auto; padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-family: var(--pixel); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }

.tokenomics-card { border: 1px solid rgba(17,19,17,.48); background: var(--ink); color: #f4f3e9; box-shadow: 4px 4px 0 rgba(49,112,62,.18); }
.tokenomics-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px; border-bottom: 1px solid rgba(201,239,200,.22); }
.tokenomics-head .small-label { color: var(--mint); }
.tokenomics-head h2 { margin: 8px 0 0; max-width: 220px; font-size: 17px; line-height: 1.05; letter-spacing: -.025em; }
.tokenomics-mark { font-family: var(--pixel); font-size: 12px; color: var(--mint); border: 1px solid rgba(201,239,200,.4); padding: 7px 8px; }
.fee-split { display: grid; }
.fee-row { display: grid; grid-template-columns: 58px 1fr; gap: 10px; padding: 13px 14px; align-items: start; }
.fee-row + .fee-row { border-top: 1px solid rgba(201,239,200,.16); }
.fee-row > strong { font-family: var(--pixel); color: var(--mint); font-size: 17px; line-height: 1; }
.fee-row div > span { display: block; font-family: var(--pixel); font-size: 9px; letter-spacing: .07em; color: #fff; }
.fee-row p { margin: 6px 0 0; font-size: 11px; line-height: 1.4; color: rgba(244,243,233,.68); }
.fee-primary { background: rgba(201,239,200,.07); }

.history-drawer { position: fixed; right: 0; top: 0; z-index: 90; width: min(430px, 92vw); height: 100vh; background: #f3f3e7; border-left: 1px solid var(--ink); transform: translateX(102%); transition: transform .24s ease; box-shadow: -20px 0 60px rgba(17,19,17,.18); }
.history-drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(12,18,13,.34); backdrop-filter: blur(2px); }
.history-head { padding: 22px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.history-head p, .history-head h2 { margin: 0; }
.history-head h2 { margin-top: 5px; font-size: 28px; }
.icon-btn { width: 38px; height: 38px; font-size: 22px; cursor: pointer; }
.history-list { overflow: auto; height: calc(100vh - 96px); padding: 12px; }
.history-item { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 13px 10px; border-bottom: 1px solid var(--line); }
.history-num { font-family: var(--pixel); font-size: 9px; opacity: .5; padding-top: 3px; }
.history-item strong { display: block; font-size: 13px; }
.history-item p { margin: 5px 0 0; font-family: var(--pixel); font-size: 9px; line-height: 1.45; opacity: .65; }
.empty-history { padding: 40px 12px; text-align: center; font-family: var(--pixel); font-size: 10px; opacity: .55; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr auto; }
  .layout { grid-template-columns: 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--line); min-height: auto; }
  .panel-scroll { grid-template-columns: 1fr 1fr; align-items: start; }
  .intro-card { grid-column: 1 / -1; }
  .panel-footer { margin-top: 0; }
}

@media (max-width: 640px) {
  .topbar { height: 62px; padding: 0 12px; }
  .brand span { display: none; }
  .brand img { width: 36px; height: 36px; }
  .ghost-btn { padding: 9px; font-size: 9px; }
  .room-wrap { padding: 9px; }
  .room-chrome { min-height: 46px; }
  .canvas-frame { box-shadow: 0 12px 30px rgba(25,51,30,.14); }
  .mobile-hint { display: block; }
  .panel-scroll { grid-template-columns: 1fr; padding: 22px 14px; }
  .intro-card h1 { font-size: 36px; }
  .panel-footer { padding: 12px 14px; }
  .drop-hint { bottom: 8px; width: calc(100% - 16px); text-align: center; }
  .spectator-badge { top: 8px; right: 8px; transform: scale(.9); transform-origin: top right; }
}

.wallet-btn { min-width: 104px; background: var(--ink); color: var(--mint); }
.wallet-btn.connected { background: var(--mint); color: var(--ink); border-color: var(--deep-green); }
.wallet-btn.busy { opacity: .62; cursor: wait; }
.move-card.ready { cursor: pointer; }
.address-link { font-family: var(--pixel); font-size: .92em; font-weight: 700; color: var(--deep-green); text-decoration: underline; text-underline-offset: 2px; }
.history-wallet { color: var(--deep-green); text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 640px) {
  .wallet-btn { min-width: 82px; }
  .top-actions { gap: 5px; }
}

@media (max-width: 760px) {
  .room-chrome { gap: 10px; }
  .room-meta { gap: 6px; }
  .clock-readout { display: none; }
  .token-strip { min-height: 34px; transform: translateY(4px); box-shadow: 3px 3px 0 rgba(17,19,17,.13); }
  .token-ticker, .token-chip { min-height: 34px; padding: 6px 8px; font-size: 7px; letter-spacing: .035em; }
  .token-ticker { font-size: 10px; padding-left: 10px; padding-right: 10px; }
  .token-chip-label { display: none; }
}

@media (max-width: 470px) {
  .room-label { gap: 7px; }
  .room-id { display: none; }
  .token-pons { max-width: 54px; overflow: hidden; }
}
