/* The look of the 2013 Android menus: green gradient buttons, the Divlit display face, space photos.
   Layout: every screen fills the window; menus scroll inside themselves and battles never scroll. */
:root {
  color-scheme: dark;
  --bg: #000;
  --fg: #f2f5f2;
  --muted: #a7b3a7;
  --green-hi: #1fdd1f;
  --green-lo: #007700;
  --panel: rgba(12, 16, 12, 0.88);
  --hud: #333;
  --red: #ff2a2a;
  --green: #22ff22;
  --display: 'Divlit', 'Roboto', Arial, sans-serif;
  --body: 'Roboto', Arial, sans-serif;
}

@font-face {
  font-family: 'Divlit';
  src: url('../assets/fonts/divlit.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Roboto';
  src: url('../assets/fonts/Roboto-Regular.ttf') format('truetype');
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--body);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button {
  font: 20px/1.2 var(--display);
  color: #fff;
  background: linear-gradient(var(--green-hi), var(--green-lo));
  border: 1px solid var(--green-lo);
  border-radius: 4px;
  padding: 10px 18px;
  cursor: pointer;
  touch-action: manipulation;
}
button:active { background: var(--green-hi); }
button:focus-visible, .world-image:focus-visible, .level-tile:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

h2, h3 { font-family: var(--display); font-weight: normal; margin: 0; text-wrap: balance; }

.loading { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; }

.screen {
  position: fixed;
  inset: 0;
  padding-block: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--bg);
  background-size: cover;
  background-position: center;
}

/* Home */
.screen-home {
  background-image: url('../assets/img/saturn_rings_800x480.png');
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 7vh, 56px);
}
.logo { width: min(78vw, 820px); height: auto; }
.menu { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(100%, 460px); }
.menu button { width: 66%; font-size: 22px; }
.menu .big { width: 100%; font-size: 26px; margin-bottom: 8px; }

/* Shared menu layout */
.screen-menu { background-image: url('../assets/img/background_orion_nebula_1024x512.jpg'); }
.bar { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.bar-title { font: 22px/1.2 var(--display); margin: 0; }
.prose {
  max-width: 68ch;
  margin-inline: auto;
  background: var(--panel);
  padding: 8px 20px 18px;
  border-radius: 4px;
  -webkit-user-select: text;
  user-select: text;
}
.prose h3 { font-size: 20px; margin-top: 16px; color: var(--green); }
.prose ul { margin: 8px 0; padding-left: 20px; }
.prose li + li { margin-top: 6px; }
.prose a { color: var(--green); }
.options label { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.options input { width: 20px; height: 20px; accent-color: var(--green-hi); flex: none; }

/* Worlds */
.worlds { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 18px; max-width: 980px; margin-inline: auto; }
.world { display: flex; flex-direction: column; gap: 10px; background: var(--panel); padding: 14px; border-radius: 4px; min-width: 0; }
.world h2 { font-size: 22px; text-align: center; }
.world-image { padding: 0; border: 0; background: none; border-radius: 2px; overflow: hidden; display: block; width: 100%; }
.world-image:active { background: none; }
.world-image img { display: block; width: 100%; height: auto; }

/* Battles in a world */
.screen-levels { background-size: cover; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; max-width: 980px; margin-inline: auto; }
.level-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--green-lo);
  font: 15px/1.2 var(--body);
  min-width: 0;
}
.level-tile:active:not(:disabled) { background: #123212; }
.level-tile:disabled { border-color: #444; cursor: not-allowed; color: var(--muted); }
.level-tile img { width: 100%; height: auto; image-rendering: auto; }
.level-number { font: 18px/1 var(--display); }
.level-stars { color: var(--green); font-variant-numeric: tabular-nums; letter-spacing: 0.08em; }
.level-tile:disabled .level-stars { color: var(--muted); }

/* Battle */
.screen-battle { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
#battle-canvas { flex: 1 1 0; min-height: 0; width: 100%; display: block; touch-action: none; background: #000; }
.hud {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--hud);
  font-size: clamp(15px, 2.6vw, 22px);
  font-variant-numeric: tabular-nums;
  padding-block: 4px calc(4px + env(safe-area-inset-bottom, 0px));
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  white-space: nowrap;
}
.hud-stats { overflow: hidden; min-width: 0; }
.hud-gap { margin-left: 1.1em; }
.hud-buttons { display: flex; gap: 6px; flex: none; }
.hud-buttons button { font-size: 14px; padding: 6px 10px; }
.red { color: var(--red); }
.green { color: var(--green); }
#hud-unit-target.missed { color: #0a660a; }
#hud-time-target.missed { color: #777; }
@media (max-width: 640px) { .hud-geos { display: none; } }

/* Dialogs */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
  overflow-y: auto;
}
.modal-box {
  width: min(100%, 620px);
  max-height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--green-lo);
  border-radius: 4px;
  padding: 18px 20px;
}
.modal-box h2 { font-size: 24px; color: var(--green); }
.modal-body p { margin: 10px 0; }
.modal-body:empty { display: none; }
.modal-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.modal-buttons button { flex: 1 1 120px; }

@media (max-height: 460px) {
  .menu { flex-direction: row; flex-wrap: wrap; justify-content: center; width: min(100%, 680px); }
  .menu button { width: auto; flex: 1 1 28%; font-size: 18px; }
  .menu .big { flex-basis: 100%; font-size: 22px; margin-bottom: 0; }
  .logo { width: min(60vw, 620px); }
}
