/* plan33.io game harness — shared conventions. Theme via :root vars. */

:root {
  --bg: #0c0a08;
  --fg: #f3e9d8;
  --muted: #9a8b74;
  --accent: #ffb445;         /* amber — primary UI accent */
  --cyan: #4de0e0;           /* cyan — secondary cipher accent */
  --locked: #ffb445;         /* exact match tile */
  --shifted: #4de0e0;        /* present, wrong slot tile */
  --void: #2a241d;           /* absent tile */
  --scrim: rgba(8, 6, 4, 0.82);
  --panel: rgba(24, 18, 12, 0.95);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: var(--bg);
}

/* ---------- corner chrome ---------- */
.chrome {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 20;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 180, 69, 0.22);
  background: rgba(255, 180, 69, 0.08);
  color: var(--fg);
  font: 600 16px/1 var(--font);
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn:hover { background: rgba(255, 180, 69, 0.16); }
.icon-btn[aria-pressed="true"] { color: var(--cyan); border-color: var(--cyan); }

/* ---------- on-screen QWERTY keyboard ---------- */
/* Always shown on coarse pointers; also usable with mouse on desktop while playing/paused. */
.keyboard {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 15;
  padding: 0 calc(6px + env(safe-area-inset-left)) 0 calc(6px + env(safe-area-inset-right));
}

body.state-playing .keyboard,
body.state-paused   .keyboard { display: block; }

.kb-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 4px 0;
}

.key-btn {
  flex: 0 1 34px;
  min-width: 26px;
  height: 46px;
  border-radius: 8px;
  border: 1px solid rgba(255, 180, 69, 0.2);
  background: rgba(255, 180, 69, 0.08);
  color: var(--fg);
  font: 700 14px/1 var(--font);
  cursor: pointer;
  touch-action: manipulation;
}
.key-btn:hover { background: rgba(255, 180, 69, 0.16); }
.key-btn:active { background: var(--accent); color: #1a1206; }

.key-btn.key-wide {
  flex: 0 1 56px;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.key-btn[data-state="locked"] {
  background: rgba(255, 180, 69, 0.85);
  border-color: var(--locked);
  color: #1a1206;
}
.key-btn[data-state="shifted"] {
  background: rgba(77, 224, 224, 0.5);
  border-color: var(--cyan);
  color: #06231f;
}
.key-btn[data-state="void"] {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

/* ---------- overlays: visibility driven purely by body state class ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  z-index: 30;
}

body.state-menu     .overlay-menu,
body.state-paused   .overlay-paused,
body.state-gameover .overlay-gameover { display: grid; }

.panel {
  width: min(440px, 100%);
  padding: 28px 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 180, 69, 0.18);
  background: var(--panel);
  text-align: center;
  animation: pop 180ms ease-out;
}

@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }

.panel h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: 1px; color: var(--accent); }
.panel h2 { margin: 0 0 14px; font-size: 24px; }
.tagline  { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.score    { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.hi       { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.reveal   { margin: 0 0 14px; color: var(--cyan); font-size: 15px; font-weight: 600; letter-spacing: 2px; }
.hint     { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.btn {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #1a1206;
  font: 700 16px/1 var(--font);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid rgba(255, 180, 69, 0.28);
}
