@font-face{font-family:PusabLocal;src:url('fonts/Pusab-Rus.ttf') format('truetype');font-display:swap}
:root{
  --bg:#111;--panel:#111;--panel2:#171717;--text:#eee;--muted:#999;--border:#555;
  --strong:#fff;--button:#eee;--buttonText:#111;--secondary:#191919;--secondaryText:#eee;
  --canvas:#050505;--grid:#1b1b1b;--accent:#9d9d9d;--shadow:rgba(0,0,0,.4);
  --footer-h:92px;--header-gap:8px;
}
*{box-sizing:border-box}
html,body{width:100%;height:100%;margin:0;background:var(--bg);color:var(--text);font-family:monospace}
html{overflow:hidden}
body{min-height:100dvh;height:100dvh;display:flex;flex-direction:column;overflow:hidden;overscroll-behavior:none}
button,input,select{font:inherit}button{touch-action:manipulation}
.site-header{
  width:min(760px,100%);height:var(--footer-h);flex:0 0 var(--footer-h);margin:0 auto;
  padding:12px 12px 10px;display:flex;align-items:center;gap:10px;position:relative;
}
.menu-mode .site-header{order:1}
.menu-mode .main-wrap{order:2}
.game-mode .site-header{
  position:fixed;left:50%;bottom:0;transform:translateX(-50%);
  z-index:40;border-top:1px solid var(--border);margin:0;background:var(--bg);
}
.game-mode .main-wrap{
  order:1;
  padding-bottom:calc(var(--footer-h) + 12px);
}
.title-row{display:flex;gap:10px;align-items:flex-start;min-width:0}
.brand-mark{width:30px;height:30px;border:1px solid #777;display:flex;align-items:center;justify-content:center;font-size:17px;flex:0 0 30px}
.site-title{font-size:24px;font-weight:700;line-height:1.15}
.site-subtitle{margin-top:4px;color:var(--muted);font-size:12px}
.header-settings{margin-left:auto;white-space:nowrap}
.main-wrap{
  width:min(760px,100%);margin:0 auto;padding:0 10px;
  min-height:0;flex:1;overflow:hidden;display:flex;flex-direction:column;
}
.screen{display:none;min-height:0}
.screen.active{display:flex}
.menu-screen{flex-direction:column;gap:8px;padding-bottom:4px;justify-content:center}
.game-screen{flex:1;flex-direction:column;min-height:0;padding-top:4px}
.panel{border:1px solid var(--border);background:var(--panel)}
.hero-panel{padding:17px;margin:0}
.kicker{font-size:11px;color:var(--muted);letter-spacing:.08em}
.hero-panel h1{margin:7px 0 9px;font-size:22px}
.hero-panel p{margin:0;color:var(--muted);line-height:1.5}
.game-list{display:flex;flex-direction:column;gap:8px}
.game-card{
  width:100%;border:1px solid var(--border);background:var(--panel2);color:var(--text);
  display:flex;align-items:center;gap:11px;padding:12px;text-align:left;cursor:pointer
}
.game-card:hover{border-color:#888}
.game-icon{width:40px;height:40px;border:1px solid #666;display:flex;align-items:center;justify-content:center;font-size:23px;flex:0 0 40px}
.game-info{display:flex;flex-direction:column;gap:3px;min-width:0}
.game-info b{font-size:16px;color:var(--text)}
.game-info small{color:var(--muted);font-size:12px}
.chev{margin-left:auto;font-size:25px;color:var(--muted)}
.info-panel{padding:12px}
.info-row{display:flex;justify-content:space-between;gap:8px;padding:5px 0;border-bottom:1px solid color-mix(in srgb,var(--border) 55%,transparent);font-size:12px}
.info-row:last-child{border-bottom:0}
.info-row span{color:var(--muted)}
.info-row b{font-weight:400;color:var(--text)}

.button{border:1px solid #999;background:var(--button);color:var(--buttonText);padding:8px 11px;min-height:36px;cursor:pointer}
.button.secondary{background:var(--secondary);color:var(--secondaryText);border-color:#666}
.button:disabled{opacity:.45;cursor:default}

.game-topbar{display:flex;align-items:center;gap:8px;flex:0 0 auto}
.game-title{flex:1;text-align:center;min-width:0}
.game-title b{display:block;font-size:18px}
.game-title small{display:block;color:var(--muted);font-size:11px;margin-top:2px}
.scorebar{
  flex:0 0 auto;display:flex;justify-content:space-between;gap:8px;border:1px solid var(--border);
  background:var(--panel2);padding:7px 10px;font-size:12px;margin:8px 0 6px
}
.scorebar span{color:var(--muted)}
.scorebar b{color:var(--text);font-weight:700}
.game-board-area{
  flex:1;min-height:30px;display:flex;align-items:center;justify-content:center;overflow:hidden;
  padding:2px 0
}
.game-canvas{
  display:block;width:auto;height:auto;max-width:100%;max-height:100%;aspect-ratio:auto;
  image-rendering:pixelated;border:1px solid #666;background:var(--canvas);box-shadow:0 8px 30px var(--shadow)
}
#snakeCanvas{aspect-ratio:1/1}
.tetris-canvas{aspect-ratio:1/2}
.pixel-area{align-items:center}
.pixel-board{
  display:grid;border:1px solid #666;background:var(--canvas);overflow:hidden;
  image-rendering:pixelated;flex:0 0 auto
}
.pixel-cell{border:1px solid rgba(0,0,0,.14);padding:0;margin:0;min-width:0;min-height:0;cursor:pointer}
.pixel-cell.cursor{outline:3px solid #fff;outline-offset:-3px;box-shadow:inset 0 0 0 1px #000;z-index:2}

.controls-panel{
  flex:0 0 auto;display:grid;grid-template-columns:repeat(3,minmax(60px,1fr));gap:6px;
  width:min(330px,100%);margin:6px auto 14px;position:relative;z-index:5
}
.dpad{border:1px solid #777;background:var(--button);color:var(--buttonText);min-height:42px;cursor:pointer;font-size:18px}
.dpad.wide{grid-column:span 3;font-size:13px}
.dpad.spacer{visibility:hidden}
.tetris-controls{grid-template-columns:repeat(3,1fr)}
.tetris-controls .dpad:nth-child(4){grid-column:1}
.tetris-controls .dpad:nth-child(5){grid-column:2 / 4}
.game-actions{flex:0 0 auto;display:flex;justify-content:center;gap:7px;margin:0 0 8px;padding-bottom:0}
.rules{padding:11px;color:var(--muted);font-size:12px;line-height:1.45}

.game-screen .game-actions{margin-bottom:0}
.game-screen{overflow:hidden}
.game-screen::after{content:"";display:block;flex:0 0 10px}


.modal{position:fixed;inset:0;background:rgba(0,0,0,.82);display:flex;align-items:center;justify-content:center;padding:10px;z-index:100}
.modal.hidden{display:none}
.modal-box{width:min(640px,100%);max-height:92dvh;display:flex;flex-direction:column;border:1px solid #666;background:var(--panel);box-shadow:0 24px 70px rgba(0,0,0,.65)}
.modal-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 12px;border-bottom:1px solid var(--border)}
.icon-button{width:32px;height:30px;background:var(--secondary);border:1px solid #666;color:var(--secondaryText);font-size:22px;cursor:pointer}
.modal-body{padding:14px;overflow:auto}
.modal-foot{display:flex;justify-content:flex-end;gap:6px;padding:10px 12px;border-top:1px solid var(--border)}
.setting-row{display:grid;grid-template-columns:1fr minmax(150px,260px);gap:10px;align-items:center;margin:0 0 10px}
.setting-row label{font-size:12px;color:var(--muted)}
.setting-control{width:100%;padding:9px;border:1px solid #777;background:var(--button);color:var(--buttonText)}
.setting-note{font-size:11px;color:var(--muted);line-height:1.45;margin:5px 0 12px}
.warning{border:1px solid #765d2a;background:#1a160e;padding:10px;color:#ddd;font-size:12px;line-height:1.5}
.confirm-row{display:flex;gap:6px;justify-content:flex-end}

.toast{
  position:fixed;left:50%;bottom:calc(var(--footer-h) + 10px);transform:translateX(-50%);
  pointer-events:none;background:var(--button);color:var(--buttonText);border:1px solid #777;
  padding:8px 11px;font-size:12px;z-index:150;display:none
}
.toast.show{display:block}

html[data-theme="white"]{
  --bg:#fff;--panel:#fff;--panel2:#f7f7f7;--text:#111;--muted:#555;--border:#888;
  --strong:#111;--button:#111;--buttonText:#fff;--secondary:#f1f1f1;--secondaryText:#111;
  --canvas:#fbfbfb;--grid:#d9d9d9;--shadow:rgba(0,0,0,.16)
}
html[data-theme="white"] .site-header{background:#fff}
html[data-theme="white"] .button.secondary{border-color:#777}
html[data-theme="white"] .game-card{background:#f7f7f7;color:#111}
html[data-theme="white"] .game-card b{color:#111}
html[data-theme="white"] .game-card small,.html[data-theme="white"] .scorebar span{color:#555}
html[data-theme="white"] .chev{color:#555}
html[data-theme="white"] .scorebar{background:#f7f7f7}
html[data-theme="white"] .game-title small,.html[data-theme="white"] .kicker{color:#555}
html[data-theme="white"] .game-canvas{background:#fbfbfb}
html[data-theme="white"] .pixel-board{background:#fbfbfb}

html[data-theme="spaceline"]{
  --bg:#071426;--panel:#091a2e;--panel2:#0d223a;--text:#e8f2ff;--muted:#7fa5c7;--border:#335675;
  --button:#dbeaff;--buttonText:#071426;--secondary:#0b2037;--secondaryText:#dbeaff;--canvas:#05101d
}
html[data-theme="geometrydash"]{
  --bg:#0e315a;--panel:#0f3766;--panel2:#15457b;--text:#f6fbff;--muted:#b0cce6;--border:#7aa6cf;
  --button:#f0f8ff;--buttonText:#0e315a;--secondary:#0b2b50;--secondaryText:#f0f8ff;--canvas:#071a31
}
html[data-theme="geometrydash"] .site-title,
html[data-theme="geometrydash"] .game-title b,
html[data-theme="geometrydash"] .hero-panel h1{font-family:PusabLocal,monospace;letter-spacing:.02em}
html[data-theme="geometrydash"] .game-card{background:#15457b;box-shadow:inset 0 -3px 0 rgba(0,0,0,.22)}
html[data-theme="geometrydash"] .panel,
html[data-theme="geometrydash"] .scorebar{box-shadow:0 4px 0 rgba(0,0,0,.2)}

@media (max-width:560px){
  :root{--footer-h:88px}
  .site-title{font-size:21px}.site-subtitle{font-size:11px}
  .hero-panel{padding:14px}
  .game-card{padding:10px}
  .setting-row{grid-template-columns:1fr}
  .dpad{min-height:40px}
  .scorebar{font-size:11px}
  .game-topbar .button{padding:7px 9px;min-height:34px}
}
@media (max-height:760px){
  :root{--footer-h:78px}
  .site-header{padding-top:7px;padding-bottom:7px}
  .site-title{font-size:19px}
  .site-subtitle{font-size:10px}
  .hero-panel h1{font-size:20px}
  .hero-panel p{line-height:1.25}
  .controls-panel{gap:4px;margin-top:4px;margin-bottom:12px}
  .dpad{min-height:36px}
  .game-actions{margin-bottom:7px}
  .game-actions .button{min-height:32px;padding:6px 10px}
}
@media (max-height:620px){
  :root{--footer-h:68px}
  .brand-mark{width:26px;height:26px;flex-basis:26px;font-size:14px}
  .site-title{font-size:17px}
  .site-subtitle{font-size:9px}
  .game-topbar{gap:5px}
  .scorebar{margin:5px 0 3px;padding:5px 8px}
  .controls-panel{width:min(300px,100%)}
  .dpad{min-height:32px;font-size:16px}
  .game-actions{margin-bottom:6px}
}
@media (max-width:380px){
  .site-header{padding-left:8px;padding-right:8px}
  .main-wrap{padding-left:7px;padding-right:7px}
  .header-settings{font-size:11px;padding:6px}
  .game-icon{width:36px;height:36px;flex-basis:36px}
}
