@import url("modes.css");
h1 { overflow-wrap: anywhere; } /* a long translated title (Swedish Tank Defense) wraps instead of widening the page */
/* Shared look and feel for the arcade games (see .claude/skills/apple-design-games/references/games.md).
   A game sets its own colours on :root and leaves everything else to this file:
     --accent      the game's one accent colour           --accent-ink  text colour on top of the accent
     --field       background of the play field
   Everything below is built from those plus the shell tokens in ../style.css. */

.wrap { max-width: 520px; margin: 0 auto; padding: 4px 16px calc(40px + env(safe-area-inset-bottom)); text-align: center; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px 0 16px; margin: calc(4px + env(safe-area-inset-top)) 0 0; }   /* env(): clear of the iPhone clock in the installed app */
.back-link:focus-visible, .btn:focus-visible, .pad button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1 {
  font-family: 'Courier New', monospace;
  font-size: 30px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 50%, transparent);
  margin: 6px 0 8px;
}
.tagline { font-family: system-ui, sans-serif; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: #b8935c; margin: 0 0 12px; }
/* board and card games keep the warmer serif title; add class="board-game" to <body> */
body.board-game h1 { font-family: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif; font-size: clamp(26px, 5vw, 38px); letter-spacing: 0.05em; text-transform: none; color: var(--text); text-shadow: 0 2px 6px rgba(0,0,0,0.6); margin: 10px 0 2px; }
.pitch { margin: 0 auto 16px; max-width: 44ch; font-size: 14px; line-height: 1.5; color: var(--text-dim); }

/* HUD: at most three things during play */
.hud {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px;
  font-family: 'Courier New', monospace; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-dim); max-width: 480px; margin: 0 auto 10px; padding: 0 4px; font-variant-numeric: tabular-nums;
}
.hud b { color: var(--accent); }

/* buttons (44px minimum height) */
.btn {
  font-family: system-ui, sans-serif; font-size: 14px; font-weight: 600;
  min-height: 44px; padding: 0 20px; border-radius: 10px; cursor: pointer;
  color: var(--text); background: rgba(255,255,255,0.06);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.primary { background: var(--accent); color: var(--accent-ink, #0c1810); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }

/* "You have a game in progress" */
.resume-box {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  max-width: 480px; margin: 0 auto 14px; padding: 12px 14px; border-radius: 12px; text-align: left; font-size: 14px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent);
}
.resume-box[hidden] { display: none; }
.resume-info { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.resume-box .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* play field + start / paused / game-over screen laid over it */
.field { position: relative; max-width: 480px; margin: 0 auto; }
.field > canvas {
  display: block; width: 100%; aspect-ratio: var(--field-ratio, 1 / 1); touch-action: none; /* --field-ratio: width / height, e.g. 1 / 2 */
  background: var(--field, #0c1810); border-radius: 10px;
  border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 15%, transparent), inset 0 0 20px rgba(0,0,0,0.6);
}
.overlay {
  position: absolute; inset: 2px; border-radius: 8px; padding: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(8,12,10,0.86);
}
.overlay[hidden] { display: none; }
.overlay h2 { margin: 0; font: 700 28px 'Courier New', monospace; letter-spacing: .04em; color: var(--accent); }
.overlay p { margin: 0; max-width: 30ch; font-size: 14px; line-height: 1.5; color: var(--text); }
.overlay .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; min-width: 160px; }

.msg { margin: 14px 0 0; font-size: 13px; color: var(--text-dim); min-height: 20px; }
.controls { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }

/* on-screen direction pad */
.pad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); gap: 4px; justify-content: center; margin-top: 18px; }
.pad button {
  background: rgba(255,255,255,0.06); color: var(--accent); border-radius: 10px; font-size: 18px; cursor: pointer; touch-action: manipulation;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.pad button:active { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* a row of action buttons instead of the 3x3 direction pad (add class="pad row") */
.pad.row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pad.row button { width: 52px; height: 48px; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }

/* How to play */
.rules { margin-top: 44px; text-align: left; }
.rules h2 { text-align: center; font-size: 20px; margin: 0 0 14px; color: var(--text); }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.rule-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; padding: 14px 16px; }
.rule-card h3 { margin: 0 0 6px; font-size: 14px; letter-spacing: .03em; color: var(--accent); }
.rule-card p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--text-dim); }
.rule-card b { color: var(--text); }

@media (prefers-reduced-motion: no-preference) {
  .overlay:not([hidden]) { animation: arcade-fade .18s ease-out; }
  @keyframes arcade-fade { from { opacity: 0; } to { opacity: 1; } }
}
