/* term.css: the phosphor-terminal look shared by the War Games pages (gc12345.hanksla.fi).
   Page = title bar (CLR / PAUSE / NEW) + CRT glass with a <pre> text screen + one row of keycaps
   + a "$ cd ../other-game" link, over a faint ASCII silhouette. No external fonts or requests. */
:root {
  --phos: #3dff7f; --phos-rgb: 61, 255, 127;
  --glass: #041a0c; --glass2: #020a05;
  --bezel: #1a1c19; --bezel-hi: #2a2d28; --page: #0a0c0a;
  --mono: "Cascadia Mono", "SF Mono", ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  color-scheme: dark;
}
[data-phos="amber"] { --phos: #ffb84a; --phos-rgb: 255, 184, 74; --glass: #1a1004; --glass2: #0a0602; }
[data-phos="white"] { --phos: #dfe8ff; --phos-rgb: 223, 232, 255; --glass: #0d1018; --glass2: #05060a; }
[data-phos="wopr"]  { --phos: #8fd6ff; --phos-rgb: 143, 214, 255; --glass: #03101c; --glass2: #01060c; }   /* WarGames */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  position: fixed; left: 0; right: 0; top: var(--vvtop, 0); height: var(--vvh, 100%);   /* see term.js: keyboard */
  margin: 0; background: radial-gradient(900px 600px at 50% 0%, #161a16, var(--page) 70%);
  color: var(--phos); font-family: var(--mono);
  display: flex; justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
           max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  overflow: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}

/* faint ASCII silhouette behind everything */
.skyline {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 0; margin: 0;
  font: 400 clamp(10px, 2.4vw, 30px)/1.1 var(--mono); white-space: pre; pointer-events: none;
  color: rgba(var(--phos-rgb), .07); text-shadow: 0 0 12px rgba(var(--phos-rgb), .12);
}

/* the terminal: bar + glass + keys + link */
.term {
  position: relative; z-index: 1;
  width: min(560px, 100%); height: 100%;
  display: grid; gap: 10px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "bar" "screen" "keys" "nav";
}
.bar { grid-area: bar; }
.screen { grid-area: screen; }
.keys { grid-area: keys; }
.nav { grid-area: nav; }

.bar {
  display: flex; align-items: center; gap: 10px; min-height: 52px;
  padding: 3px 4px 3px 12px; border-radius: 10px;
  background: linear-gradient(180deg, var(--bezel-hi), var(--bezel));
  border: 1px solid #000; box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  color: #9aa39a; font-size: 13px; letter-spacing: .04em; min-width: 0;
}
.dots { display: flex; gap: 6px; flex: none; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: #3a3e38; box-shadow: inset 0 0 0 1px rgba(0,0,0,.5); }
.dots i:first-child { background: rgb(var(--phos-rgb)); box-shadow: 0 0 8px rgba(var(--phos-rgb), .8); }
.title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbtns { display: flex; gap: 4px; flex: none; }
.tbtn {
  min-height: 44px; min-width: 52px; padding: 0 8px; border-radius: 6px; cursor: pointer;
  font: 600 12px var(--mono); letter-spacing: .08em; color: #c9d1c9;
  background: #111310; border: 1px solid #000; box-shadow: inset 0 1px 0 rgba(255,255,255,.07);
}
.tbtn:hover { color: var(--phos); }
.tbtn:focus-visible, .key:focus-visible, .nav a:focus-visible { outline: 2px solid var(--phos); outline-offset: 2px; }

/* glass: phosphor glow, scanlines, vignette, a faint flicker */
.screen {
  position: relative; min-height: 0; overflow: hidden;
  display: grid; place-items: center; padding: 12px;
  border-radius: 18px / 22px;
  background: radial-gradient(ellipse at 50% 45%, var(--glass), var(--glass2) 85%);
  border: 10px solid var(--bezel);
  box-shadow: 0 0 0 1px #000, inset 0 0 40px rgba(0,0,0,.85), inset 0 0 6px rgba(var(--phos-rgb), .15),
              0 20px 60px rgba(0,0,0,.6);
  cursor: pointer; touch-action: manipulation;
}
.screen::before {   /* scanlines */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: repeating-linear-gradient(180deg, rgba(0,0,0,.28) 0 1px, transparent 1px 3px);
}
.screen::after {    /* vignette + glare */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0,0,0,.55)),
              linear-gradient(160deg, rgba(255,255,255,.05), transparent 35%);
  animation: flicker 6s steps(1) infinite;
}
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: .82; } 48% { opacity: 1; } 81% { opacity: .9; } 82% { opacity: 1; } }

#out {
  margin: 0; position: relative; z-index: 1;
  font: 400 16px/1.15 var(--mono); letter-spacing: 0; white-space: pre;
  color: rgba(var(--phos-rgb), .78);
  text-shadow: 0 0 2px rgba(var(--phos-rgb), .9), 0 0 9px rgba(var(--phos-rgb), .45);
}
#out .e { color: rgba(var(--phos-rgb), .22); text-shadow: none; }       /* empty cell */
#out .w { color: rgba(var(--phos-rgb), .6); }                             /* walls, frames */
#out .b { color: rgba(var(--phos-rgb), .8); }                             /* settled blocks, ships */
#out .a { color: #fff; text-shadow: 0 0 3px var(--phos), 0 0 12px var(--phos); }   /* active / cursor */
#out .g { color: rgba(var(--phos-rgb), .35); text-shadow: none; }        /* shadow, misses */
#out .f { color: #fff; text-shadow: 0 0 6px var(--phos), 0 0 18px var(--phos); }   /* flashing */
#out .o { color: #fff; text-shadow: 0 0 4px var(--phos), 0 0 14px var(--phos); }   /* overlay / headline text */
#out .d { color: rgba(var(--phos-rgb), .5); }                             /* labels, prompt */
#out .v { color: var(--phos); }                                           /* values */
#out .art { color: rgba(var(--phos-rgb), .7); }                           /* title-screen ASCII art */
#out .c { background: var(--phos); color: var(--glass2); text-shadow: none; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { background: transparent; color: inherit; } }
#out .cur { color: #fff; animation: blink3 1s steps(1) infinite; }
@keyframes blink3 { 50% { opacity: 0; } }

/* console: scrolling text + a command line instead of a fixed text screen */
.screen.console { display: block; padding: 0; cursor: text; }
.screen .scroll { position: absolute; inset: 0; z-index: 1; overflow-y: auto; overflow-x: hidden;
                  padding: 14px 16px 18px; scrollbar-width: none; overscroll-behavior: contain; }
.screen .scroll::-webkit-scrollbar { display: none; }
.console #out { white-space: pre-wrap; overflow-wrap: anywhere; }
.cmdline { position: relative; z-index: 1; display: flex; align-items: baseline; gap: .6ch; margin-top: 2px;
           font: 400 16px/1.15 var(--mono); color: rgba(var(--phos-rgb), .6); }
.cmdline[hidden] { display: none; }
.cmdline label { flex: none; white-space: pre; text-shadow: 0 0 6px rgba(var(--phos-rgb), .4); }
.cmdline input {
  flex: 1; min-width: 0; padding: 0; margin: 0; border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--phos); caret-color: var(--phos); text-shadow: 0 0 3px rgba(var(--phos-rgb), .9), 0 0 9px rgba(var(--phos-rgb), .45);
}
.key.word b { font-size: 15px; letter-spacing: .02em; }
.keys.coords { grid-template-columns: repeat(8, minmax(0, 1fr)) minmax(0, 1.4fr); grid-auto-flow: row; gap: 6px; }
.keys.coords .key { min-height: 50px; padding: 4px 0 7px; }
.keys.coords .key b { font-size: 20px; }
.keys.coords .cancel { grid-column: 9; grid-row: 1 / span 2; }
.keys.coords .cancel small { font-size: 9px; letter-spacing: .04em; }

/* keys: one row of keycaps with a hard bottom edge */
.keys { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.key {
  position: relative; min-height: 64px; padding: 6px 2px 10px; border-radius: 10px; cursor: pointer;
  display: grid; place-items: center; align-content: center; gap: 3px;
  font-family: var(--mono); color: #d4dcd4;
  background: linear-gradient(180deg, #2b2e29, #1c1e1b);
  border: 1px solid #000;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 4px 0 #0c0d0b, 0 6px 12px rgba(0,0,0,.5);
  touch-action: none; -webkit-user-select: none; user-select: none;
  transition: transform .04s, box-shadow .04s;
}
.key b { font-size: 24px; line-height: 1; font-weight: 700; color: var(--phos); text-shadow: 0 0 8px rgba(var(--phos-rgb), .6); }
.key svg { width: 26px; height: 26px; display: block; color: var(--phos); filter: drop-shadow(0 0 4px rgba(var(--phos-rgb), .6)); }
.key small { font-size: 10px; letter-spacing: .1em; color: #7d877d; white-space: nowrap; }
.key.hot { background: linear-gradient(180deg, #33372f, #22251f); }
.key.down, .key:active {
  transform: translateY(3px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 1px 0 #0c0d0b, 0 2px 4px rgba(0,0,0,.5);
}
.key.down b { color: #fff; }

/* "$ cd ../other" link + keyboard hint */
.nav {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: #5f685f; letter-spacing: .03em; min-width: 0;
}
.nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px;
  color: rgba(var(--phos-rgb), .75); text-decoration: none; text-shadow: 0 0 6px rgba(var(--phos-rgb), .35);
}
.nav a:hover { color: var(--phos); }
.nav a::after { content: "_"; margin-left: 2px; animation: blink2 1s steps(1) infinite; }
@keyframes blink2 { 50% { opacity: 0; } }
.hint { margin: 0; }
@media (hover: none), (pointer: coarse) { .hint { display: none; } }

/* narrow phones */
@media (max-width: 400px) {
  .host { display: none; }
  .tbtn { min-width: 46px; }
  .key small { font-size: 9px; letter-spacing: .04em; }
  .keys { gap: 6px; }
}

/* phone in landscape: glass on the left, bar + keys on the right */
@media (orientation: landscape) and (max-height: 560px) {
  .term {
    width: 100%; max-width: 900px; gap: 8px;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "screen bar" "screen ." "screen keys" "screen nav";
  }
  .bar { min-height: 48px; padding-top: 2px; padding-bottom: 2px; }
  .screen { padding: 6px; border-width: 8px; }
  .key { min-height: 60px; }
  .nav { justify-content: center; }
  .skyline { font-size: 9px; }
}

/* phone keyboard open: give the glass every pixel; the keyboard replaces the key row */
html.kbd .keys, html.kbd .nav, html.kbd .skyline { display: none; }
html.kbd .term { gap: 6px; }
html.kbd .bar { min-height: 44px; padding-top: 0; padding-bottom: 0; }
html.kbd body { padding-bottom: 6px; }

/* tappable words in the console: games, cards, squares */
.tok { cursor: pointer; text-decoration: underline dotted rgba(var(--phos-rgb), .45); text-underline-offset: 3px;
       border-radius: 3px; padding: 0 1px; touch-action: manipulation; }
/* in the console, names and files get a finger-sized tap area without moving the text */
/* touch screens: more room between console lines, so every name has its own finger-sized strip */
@media (pointer: coarse) {
  .console #out { line-height: 1.75; }
  .console #out .tok:not(.sq) { padding: 3px 4px; margin: 0 -4px; }
}
.tok:hover, .tok:active { background: rgba(var(--phos-rgb), .18); }
.tok.off { cursor: default; text-decoration: none; opacity: .4; }
.tok.sq { text-decoration: none; padding: 0; border-radius: 0; }
.tok.spent { cursor: default; text-decoration: none; background: none; }
/* game boards: shaded dark squares, highlighted last move, red suits */
#out .sqd { background: rgba(var(--phos-rgb), .10); }
#out .hl { background: rgba(var(--phos-rgb), .30); color: #fff; }
#out .red { color: #fff; text-shadow: 0 0 4px var(--phos), 0 0 12px var(--phos); }
#out .blk { color: rgba(var(--phos-rgb), .85); }

@media (prefers-reduced-motion: reduce) {
  .screen::after, #out .c, .nav a::after { animation: none; }
}
