@font-face { font-family: 'Fredoka'; font-weight: 400; font-display: swap; src: url('fonts/fredoka-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 600; font-display: swap; src: url('fonts/fredoka-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: swap; src: url('fonts/fredoka-latin-700-normal.woff2') format('woff2'); }

:root {
  color-scheme: dark;
  --ink: #fff6e8;
  --dim: #b9cbc7;
  --gold: #ffd166;
  --accent: #ff8a3d;
  --link: #8cd6ff;
  --line: rgba(255, 255, 255, 0.1);
  --fredoka: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 0%, #1f5a4f 0%, #0b1f24 60%) fixed;
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header.site, main.card, footer { width: min(1180px, 100% - 32px); margin: 0 auto; flex: none; }

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0;
}

.logo {
  font-family: var(--fredoka);
  font-size: clamp(30px, 6vw, 44px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  text-decoration: none;
}

.logo span {
  display: inline-block;
  color: var(--c);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 24px color-mix(in srgb, var(--c) 45%, transparent);
  animation: letter-bounce 2.8s ease-in-out infinite;
  animation-delay: var(--d);
}

@keyframes letter-bounce { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-8px); } }

h1, h2, h3, .play, .ghost, .coin, select, .toolbar, kbd { font-family: var(--fredoka); }

.actions { display: flex; gap: 10px; align-items: center; }

.play {
  padding: 9px 18px;
  border-radius: 12px;
  background: var(--accent);
  color: #1b1208;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 0 #b3561a;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}

.play:hover, .ghost:hover { filter: brightness(1.12); }
.play:active, .ghost:active { transform: translateY(3px); box-shadow: 0 1px 0 #b3561a; }

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}

.ghost:active { box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.ghost.icon { padding: 7px 9px; }

main.card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 24px clamp(16px, 3vw, 36px);
  border-radius: 22px;
  background: rgba(8, 20, 24, 0.82);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.head { flex: none; margin-bottom: 16px; }
h1 { margin: 0 0 4px; font-size: clamp(24px, 3.4vw, 34px); line-height: 1.15; color: var(--gold); }
.head p { margin: 0; color: var(--dim); }
strong { color: #fff; }
.red { color: #ff6a6e; }

.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 32px;
  align-items: flex-start;
  justify-content: center;
}

.game { flex: none; display: flex; flex-direction: column; align-items: center; }

.screen {
  position: relative;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.35), 0 12px 30px rgba(0, 0, 0, 0.5);
}

.screen canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }

.screen:fullscreen {
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw !important;
  height: 100vh !important;
}
.screen:fullscreen canvas { width: auto; height: 100%; aspect-ratio: 256 / 240; }

.crt {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: none;
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.45) 100%);
  mix-blend-mode: multiply;
}
.screen.crt-on .crt { display: block; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  background: rgba(8, 20, 24, 0.75);
  border: 0;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.overlay[hidden] { display: none; }
.coin {
  font-size: clamp(22px, 4.5vw, 34px);
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 24px rgba(255, 209, 102, 0.4);
  animation: coin-pulse 1.1s ease-in-out infinite;
}
.hint { color: var(--dim); font-size: 14px; }
@keyframes coin-pulse { 50% { transform: scale(1.06); opacity: 0.75; } }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  font-size: 15px;
}

.volume, .music, .toggle { display: flex; align-items: center; gap: 8px; color: var(--dim); font-weight: 600; }
.volume input { width: 110px; accent-color: var(--accent); }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

select {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 5px 10px;
  cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent); }
select option { background: #10282d; }

.info {
  width: 340px;
  flex: none;
  align-self: stretch;
  overflow-y: auto;
  padding-right: 6px;
}

h2 { margin: 0 0 8px; font-size: 21px; color: var(--gold); }
.info h2:not(:first-of-type) { margin-top: 26px; }
.info p, .info ul { margin: 0 0 12px; }
.info ul { padding-left: 22px; }
.info li { margin-bottom: 6px; }
li::marker { color: var(--gold); }
a { color: var(--link); }
.dim { color: var(--dim); }
.small { font-size: 14px; }

.keys { border-collapse: collapse; width: 100%; margin-bottom: 8px; }
.keys td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.keys td:last-child { text-align: right; white-space: nowrap; }

kbd {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  padding: 0 7px;
  margin-left: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  padding: 14px 0 18px;
  color: var(--dim);
  font-size: 14px;
}
footer a { color: var(--dim); }

.info-btn, .info-close { display: none; }

.touch { display: none; }

@media (pointer: coarse) {
  .touch {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 16px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }
  .toolbar .toggle, #fullscreen { display: none; }
}

.touch button {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  border: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  font: 700 15px var(--fredoka);
  touch-action: none;
}
.touch button.on { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); filter: brightness(1.2); }

.dpad { display: grid; grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 50px); gap: 2px; }
.dpad .up { grid-area: 1 / 2; border-radius: 12px 12px 4px 4px; }
.dpad .left { grid-area: 2 / 1; border-radius: 12px 4px 4px 12px; }
.dpad .right { grid-area: 2 / 3; border-radius: 4px 12px 12px 4px; }
.dpad .down { grid-area: 3 / 2; border-radius: 4px 4px 12px 12px; }

.mid { display: flex; flex-direction: column; gap: 12px; }
.pill { border-radius: 99px; padding: 8px 12px; font-size: 12px !important; }

.ab { display: flex; gap: 14px; justify-content: flex-end; }
.touch .round { width: 64px; height: 64px; border-radius: 50%; font-size: 20px; background: var(--accent); color: #1b1208; box-shadow: 0 4px 0 #b3561a; }
.touch .round.on { box-shadow: 0 1px 0 #b3561a; }
.ab .round:last-child { margin-top: -28px; }

@media (max-width: 900px) {
  .info {
    display: none;
    position: fixed;
    inset: 12px;
    width: auto;
    z-index: 10;
    padding: 22px;
    border-radius: 22px;
    background: rgba(8, 20, 24, 0.97);
    border: 1px solid var(--line);
  }
  body.show-info .info { display: block; }
  .info-btn { display: inline-flex; }
  .info-close { display: inline-flex; float: right; position: sticky; top: 0; }
  footer { display: none; }
  .head p { display: none; }
}

@media (max-width: 560px) {
  header.site, main.card { width: calc(100% - 20px); }
  main.card { padding: 14px; margin-bottom: 10px; }
  .head { margin-bottom: 10px; }
  .volume input { width: 80px; }
}

@media (max-height: 760px) {
  header.site { padding: 10px 0; }
  .head p { display: none; }
  .head { margin-bottom: 10px; }
  main.card { padding-top: 16px; padding-bottom: 16px; }
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: rgba(255, 209, 102, 0.35); background-clip: padding-box; border: 3px solid transparent; border-radius: 99px; }

.controls-btn { margin: 4px 0 22px; }
.info h2:not(:first-of-type) { margin-top: 0; }
.info { overflow-y: hidden; }

.modal {
  width: min(440px, calc(100% - 32px));
  padding: 24px 26px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(8, 20, 24, 0.97);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.modal[open] { animation: modal-in 0.35s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
.modal::backdrop { background: rgba(4, 12, 14, 0.6); backdrop-filter: blur(3px); }
.modal h2 { margin-top: 0; }
.modal-close { float: right; margin: -4px -6px 8px 8px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }

@media (max-width: 900px) { .info { overflow-y: auto; } }
.info .row { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 24px; }
.info .row a.ghost { text-decoration: none; }
