@font-face {
  font-family: "Toon Latin";
  src: url("../fonts/baloo2-latin.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Toon Kurdish";
  src: url("../fonts/kurdish-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1a1440;
  --paper: #fffaf2;
  --yellow: #ffd23f;
  --pink: #ff5fa2;
  --orange: #ff9f43;
  --blue: #4d7cff;
  --app-h: 100dvh;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  background: #140e36;
  color: var(--paper);
  font-family: "Toon Latin", "Trebuchet MS", "Segoe UI", sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
html[lang="ckb"] body {
  font-family: "Toon Kurdish", "Noto Naskh Arabic", "Noto Sans Arabic", "Geeza Pro", Tahoma, sans-serif;
}
button { font: inherit; color: inherit; }
button {
  border: 3px solid var(--yellow);
  background: #3a3170;
  color: var(--paper);
  border-radius: 14px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}
button.on { background: var(--yellow); color: var(--ink); }
button:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

#app { position: fixed; inset: 0; height: var(--app-h); width: 100%; overflow: hidden; }
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#hud {
  position: absolute;
  z-index: 4;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
#hud button { pointer-events: auto; min-width: 44px; min-height: 44px; }
.scoreline {
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(26, 20, 64, 0.88);
  border: 3px solid var(--yellow);
  border-radius: 999px;
  padding: 4px 12px;
}
.games {
  background: var(--yellow);
  color: var(--ink);
  border-radius: 10px;
  min-width: 1.7rem;
  text-align: center;
  padding: 2px 6px;
}
.goal { opacity: 0.85; font-size: 0.8rem; letter-spacing: 0.02em; }

#banner {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: calc(max(8px, env(safe-area-inset-top)) + 58px);
  transform: translateX(-50%);
  margin: 0;
  background: var(--yellow);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 14px;
  pointer-events: none;
  text-align: center;
  max-width: min(92vw, 560px);
}

#touch {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  padding:
    calc(max(8px, env(safe-area-inset-top)) + 54px)
    max(0px, env(safe-area-inset-right))
    max(0px, env(safe-area-inset-bottom))
    max(0px, env(safe-area-inset-left));
  pointer-events: none;
}
#touch.is-on { display: flex; }
#touch.portrait { flex-direction: column; }
#touch.landscape { flex-direction: row; }
#touch.portrait [data-zone="1"] { order: 1; }
#touch.portrait [data-zone="0"] { order: 2; }
.half {
  flex: 1;
  position: relative;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.half span {
  border: 2px dashed rgba(255, 250, 242, 0.45);
  border-radius: 16px;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.panel {
  position: absolute;
  z-index: 6;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  top: max(10px, env(safe-area-inset-top));
  margin: 0 auto;
  width: min(680px, calc(100% - 24px));
  max-height: calc(var(--app-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px);
  overflow: auto;
  touch-action: pan-y;
  background: #241a52;
  color: var(--paper);
  border: 4px solid var(--yellow);
  border-radius: 28px;
  padding: 16px 18px 14px;
}
.studio { margin: 0; color: var(--pink); }
h1 { margin: 0 0 4px; font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1; color: var(--yellow); }
.tag { margin: 0 0 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.row button { flex: 1 1 120px; }
.go {
  width: 100%;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  color: white;
  border-color: var(--ink);
  font-size: 1.25rem;
  min-height: 52px;
  margin: 4px 0 8px;
}
details p { margin: 6px 0; }
.credit { margin: 4px 0; }
.owner {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
  color: rgba(244, 241, 255, 0.55);
}
.langs { display: flex; flex-wrap: wrap; gap: 8px; }
.langs button, .credit { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 720px) {
  #hud { gap: 4px; }
  #hud button { padding: 4px 8px; font-size: 0.78rem; }
  .scoreline { gap: 4px; padding: 2px 8px; font-size: 0.85rem; }
  .who { font-size: 0.8rem; }
}

@media (max-height: 480px) {
  h1 { font-size: 1.4rem; }
  .tag { display: none; }
  .panel { padding: 8px 10px; }
  #menu {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    column-gap: 10px;
  }
  #menu .brand { grid-column: 1; }
  #menu .choices { grid-column: 2; }
  #menu .help, #menu .credit, #menu .owner, #menu .langs { grid-column: 1 / -1; }
  .go { min-height: 42px; font-size: 1.05rem; }
}
