@font-face {
  font-family: "Press Start 2P Local";
  src: url("fonts/PressStart2P-latin.ttf") format("truetype");
  font-display: block;
}

/* Keep desktop UI scale independent of browser/embed viewport width. */
html { font-size: 19px; }

  :root {
    --ink: #17131b;
    --ink-soft: #292332;
    --slot: #72707b;
    --panel: #c9c4c2;
    --grass: #5fa832;
    --grass-hi: #83d44c;
    --dirt: #392417;
    --gold: #ffd94a;
    --cyan: #8be8e1;
    --pink: #ff80c7;
    --px: "Press Start 2P Local", ui-monospace, Consolas, monospace;
  }

  * { box-sizing: border-box; }

  html, body { height: 100%; margin: 0; overflow: hidden; background: #7ec0ee; overscroll-behavior: none; }

  body {
    font-family: var(--px);
    -webkit-font-smoothing: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none; -webkit-user-select: none;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' shape-rendering='crispEdges'%3E%3Crect x='16' y='3' width='9' height='5' fill='%23c6c6c6' stroke='%231b1b1b' stroke-width='2'/%3E%3Crect x='5' y='14' width='16' height='5' fill='%238b6239' stroke='%231b1b1b' stroke-width='2' transform='rotate(-45 13 16)'/%3E%3C/svg%3E") 4 4, crosshair;
  }

  #world { position: fixed; inset: 0; z-index: 0; display: block; image-rendering: pixelated; touch-action: none; }

  .scan {
    position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .07;
    background: repeating-linear-gradient(180deg, rgba(0,0,0,.7) 0 1px, transparent 1px 3px);
  }
  .vig {
    position: fixed; inset: 0; z-index: 1; pointer-events: none;
    background: radial-gradient(ellipse at 50% 45%, transparent 44%, rgba(0,0,0,.45) 100%);
  }

  .stage { position: fixed; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center;
           justify-content: center; gap: 1.7rem; padding: 1rem 1rem 8rem; pointer-events: none; text-align: center; }

  .brand-strap { display: flex; align-items: center; gap: .7rem; max-width: 92vw; color: #fff; font-size: .42rem;
                 line-height: 1.5; letter-spacing: .08em; text-shadow: 2px 2px 0 #000; }
  .brand-strap::before, .brand-strap::after { content: ""; width: 2.2rem; height: 3px; background: var(--gold);
                                               box-shadow: 0 3px 0 #000; }
  .stamp { padding: .45em .6em; color: var(--ink); background: var(--gold); border: 2px solid #000;
           box-shadow: 3px 3px 0 rgba(0,0,0,.5); transform: rotate(2deg); }

  .wm {
    margin: 0; font-size: clamp(1.45rem, 5.6vw, 3.2rem); line-height: 1.25;
    color: #fff; letter-spacing: .05em;
    text-shadow:
      4px 0 0 var(--dirt), -4px 0 0 var(--dirt), 0 4px 0 var(--dirt), 0 -4px 0 var(--dirt),
      4px 4px 0 var(--dirt), -4px -4px 0 var(--dirt), 4px -4px 0 var(--dirt), -4px 4px 0 var(--dirt),
      10px 10px 0 rgba(0,0,0,.42);
    animation: bob 3.6s ease-in-out infinite;
  }
  @keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }

  .tag {
    margin: -.3rem 0 .2rem; font-size: clamp(.48rem, 1.25vw, .68rem); line-height: 1.8;
    color: var(--gold);
    text-shadow:
      3px 0 0 #000, -3px 0 0 #000, 0 3px 0 #000, 0 -3px 0 #000,
      3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000,
      5px 6px 0 rgba(0,0,0,.5);
    transform: rotate(-3deg); animation: splash 1.05s ease-in-out infinite; max-width: 92vw;
  }
  @keyframes splash { 0%,100%{transform:rotate(-4deg) scale(1)} 50%{transform:rotate(-4deg) scale(1.07)} }

  .panel { pointer-events: auto; display: flex; flex-direction: column; gap: .55rem; width: min(360px, 88vw); padding: 1rem;
           background: var(--panel); border: 3px solid var(--ink);
           box-shadow: inset 3px 3px 0 rgba(255,255,255,.55), inset -3px -3px 0 rgba(0,0,0,.32),
                       0 0 0 3px rgba(0,0,0,.25), 9px 9px 0 rgba(0,0,0,.32); }

  .btn {
    appearance: none; display: flex; align-items: center; justify-content: center;
    width: 100%; padding: .95em .8em; font-family: var(--px); font-size: .74rem;
    line-height: 1.4; text-decoration: none; color: #fff; background: var(--slot);
    border: 3px solid var(--ink);
    box-shadow: inset 2px 2px 0 rgba(255,255,255,.42), inset -2px -2px 0 rgba(0,0,0,.36);
    text-shadow: 2px 2px 0 rgba(0,0,0,.55); cursor: inherit;
    transition: background-color .1s steps(2), transform .06s steps(1);
  }
  .btn:hover { background: #96939f; }
  .btn:active { transform: translateY(2px); box-shadow: inset 2px 2px 0 rgba(0,0,0,.3); }
  .btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
  .btn-play { background: var(--grass); font-size: .82rem; padding: 1.05em .8em; }
  .btn-play:hover { background: var(--grass-hi); }
  .row { display: flex; gap: .45rem; }
  .row .btn { flex: 1; min-width: 0; font-size: clamp(.42rem, 1.6vw, .55rem); padding: .85em .2em; }

  .foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
    gap: .5em; margin-top: .2rem; font-size: .45rem; line-height: 1.9; color: #3d3d3d;
  }
  .foot button {
    appearance: none; border: none; background: none; padding: 0; font: inherit;
    color: #1f5c9e; cursor: inherit; text-decoration: underline;
  }
  .foot a { color:#3d3d3d; text-decoration:underline; pointer-events:auto; }
  .foot button:hover, .foot button.ok, .foot a:hover { color: #2c8a1f; }
  .foot a:focus-visible { outline:2px solid var(--gold); outline-offset:2px; }
  .foot button.ok { text-decoration: none; }

  .hotbar {
    position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 4;
    display: flex; padding: 3px; background: rgba(18,18,18,.76); border: 3px solid rgba(0,0,0,.82); max-width: calc(100vw - 24px);
  }
  .slot {
    position: relative; width: 3rem; height: 3rem; background: rgba(139,139,139,.85);
    border: 2px solid rgba(0,0,0,.45);
    box-shadow: inset 2px 2px 0 rgba(255,255,255,.28), inset -2px -2px 0 rgba(0,0,0,.3);
    display: flex; align-items: center; justify-content: center; cursor: inherit; padding: 0; appearance: none;
  }
  .slot.sel { outline: 3px solid #fff; outline-offset: 1px; z-index: 1; }
  .slot canvas { width: 2rem; height: 2rem; image-rendering: pixelated; }
  .slot .q { position: absolute; right: 2px; bottom: 1px; font-size: .5rem; color: #fff;
             text-shadow: 2px 2px 0 #000; pointer-events: none; }

  /* stacked above the hotbar so it can never overlap the slots at any width */
  #mode {
    position: fixed; bottom: 4.3rem; z-index: 5; width: auto; font-size: .5rem;
    padding: .8em .9em; left: 50%; transform: translateX(-50%); white-space: nowrap;
  }
  #mode.build { background: #2f6fb8; }

  .hint {
    position: fixed; left: 50%; bottom: 7.6rem; transform: translateX(-50%); z-index: 4;
    font-size: .52rem; line-height: 1.9; color: #fff; text-align: center;
    text-shadow: 2px 2px 0 rgba(0,0,0,.9); pointer-events: none;
    transition: opacity .6s ease; max-width: 94vw; white-space: nowrap;
  }
  .hint-short { display: none; }

  .stats { position: fixed; left: 12px; top: 12px; z-index: 4; padding: .55rem .65rem; font-size: .46rem; line-height: 2.05;
           color: #fff; background: rgba(23,19,27,.72); border: 2px solid rgba(0,0,0,.75); box-shadow: 4px 4px 0 rgba(0,0,0,.3);
           text-shadow: 2px 2px 0 rgba(0,0,0,.9); pointer-events: none; }
  .stats b { color: var(--gold); font-weight: normal; }
  .stats .c { color: #9fd6ff; }

  #dont { position: fixed; right: 12px; bottom: 12px; z-index: 5; width: auto; font-size: .5rem; padding: .85em 1.1em;
           color: #fff; background: #a63b8f; animation: nag 2.2s steps(2) infinite; }
  @keyframes nag { 0%,100%{background:var(--slot)} 50%{background:#a63b8f} }

  .chat {
    position: fixed; left: 12px; bottom: 12px; z-index: 4;
    display: flex; flex-direction: column-reverse; gap: .3rem; max-width: 45vw; pointer-events: none;
  }
  .chat span {
    font-size: .45rem; line-height: 1.75; color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.9);
    background: rgba(0,0,0,.32); padding: 3px 6px;
  }

  .adv {
    position: fixed; top: 14px; left: 50%; z-index: 8; display: flex; align-items: center;
    gap: .75rem; padding: .6em 1em; background: #1c1526; border: 3px solid #0e0a14;
    box-shadow: inset 2px 2px 0 rgba(255,255,255,.12), 7px 7px 0 rgba(0,0,0,.38);
    pointer-events: none; white-space: nowrap;
  }
  .adv canvas { width: 2rem; height: 2rem; image-rendering: pixelated; }
  .adv .t { font-size: .55rem; color: var(--gold); line-height: 1.6; }
  .adv .s { font-size: .62rem; color: #fff; margin-top: 5px; line-height: 1.6; }

  .float { position: fixed; z-index: 7; font-size: .6rem; color: #fff;
           text-shadow: 2px 2px 0 #000; pointer-events: none; white-space: nowrap; }
  .flash { position: fixed; inset: 0; z-index: 6; pointer-events: none;
           background: radial-gradient(circle at 50% 45%, rgba(190,45,210,.6), rgba(90,10,110,.3) 55%, transparent 78%); }
  #boot {
    position: fixed; inset: 0; z-index: 20; background: #0d1610; display: flex;
    flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
    transition: opacity .4s ease;
  }
  #boot.gone { opacity: 0; pointer-events: none; }
  #boot p { margin: 0; font-size: .62rem; line-height: 1.8; color: #fff; }
  #boot .bar { width: min(280px, 68vw); height: 20px; background: #2a2a2a; border: 3px solid #000; padding: 2px; }
  #boot .fill { height: 100%; width: 0%; background: var(--grass); }

  .crosshair { position: fixed; left: 50%; top: 50%; width: 16px; height: 16px; transform: translate(-50%, -50%); z-index: 2;
               pointer-events: none; opacity: .45; }
  .crosshair::before, .crosshair::after { content: ""; position: absolute; background: #fff; box-shadow: 2px 2px 0 #000; }
  .crosshair::before { left: 7px; top: 0; width: 2px; height: 16px; }
  .crosshair::after { left: 0; top: 7px; width: 16px; height: 2px; }

  @media (max-width: 900px) {
    .chat { bottom: 8.4rem; max-width: 62vw; }
  }
  @media (max-width: 640px) {
    .stage { gap: .75rem; justify-content: flex-start; padding: 1rem .6rem 9rem; }
    .brand-strap { font-size: .34rem; gap: .35rem; }
    .brand-strap::before, .brand-strap::after { width: 1rem; }
    .wm { font-size: clamp(1.35rem, 11vw, 2.25rem); }
    .tag { margin: 0 0 .2rem; font-size: .42rem; max-width: 94vw; }
    .panel { width: min(430px, calc(100vw - 1.2rem)); padding: .75rem; }
    .panel-copy { font-size: .43rem; line-height: 1.75; }
    .panel-head { font-size: .35rem; }
    .btn-play { font-size: .62rem; }
    .row { gap: .25rem; }
    .slot { width: 2.3rem; height: 2.3rem; }
    .slot canvas { width: 1.5rem; height: 1.5rem; }
    .slot .q { font-size: .42rem; }
    .stats { display: none; }
    .hint { font-size: .4rem; bottom: 6.6rem; }
    .hint-wide { display: none; }
    .hint-short { display: inline; }
    #dont { right: 8px; bottom: 6.8rem; font-size: .42rem; padding: .7em .8em; }
    #mode { bottom: 3.6rem; font-size: .44rem; }
    .chat { display: none; }
  }
  @media (max-width: 640px) and (max-height: 620px) {
    .stage { gap: .8rem; justify-content: flex-start; padding-top: 2.5rem; }
    .wm { font-size: clamp(1.1rem, 5vw, 1.8rem); }
  }

  @media (prefers-reduced-motion: reduce) {
    .wm, .tag, #dont { animation: none; }
    #boot { display: none; }
  }
