/* Roadhold - mobile-web, portrait, touch-only static bundle. */

:root {
  --ink: #101820;
  --night: #172430;
  --paper: #f3ead8;
  --muted: #b7c0b2;
  --field: #5e8f6b;
  --field-dark: #2f6046;
  --water: #5fa6c7;
  --ember: #d35d46;
  --gold: #d8b15e;
  --clay: #9f6f50;
  --panel: rgba(16, 24, 32, 0.88);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--paper);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font: inherit;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  min-width: 0;
  padding:
    max(10px, var(--safe-top))
    max(10px, var(--safe-right))
    max(10px, var(--safe-bottom))
    max(10px, var(--safe-left));
  background:
    linear-gradient(180deg, #24384b 0%, #314d55 31%, #1f4233 66%, #101820 100%);
}

#hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  min-height: 54px;
  padding: 4px 0 10px;
}

#hud[hidden],
#commands[hidden] {
  display: none;
}

.stat {
  min-width: 0;
  text-align: center;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.1;
}

.stat span:last-child {
  display: block;
  margin-top: 2px;
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
}

.keep span:last-child {
  color: #9fe4bb;
}

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #213540;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 18px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(16, 24, 32, 0.86), rgba(16, 24, 32, 0.94));
}

.panel[hidden] {
  display: none;
}

.panel h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
}

.panel h1 {
  max-width: 310px;
  color: var(--gold);
  font-size: 42px;
  line-height: 0.96;
}

.panel h2 {
  color: var(--gold);
  font-size: 32px;
  line-height: 1;
}

.tagline {
  max-width: 260px;
  margin: 0;
  color: #dbe5cf;
  font-size: 17px;
  line-height: 1.4;
}

.result {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.result strong {
  color: #9fe4bb;
  font-size: 24px;
}

.result.sub {
  color: #d4ddcf;
}

.result.sub strong {
  color: var(--paper);
}

.actions {
  display: flex;
  flex-direction: column;
  width: min(100%, 228px);
  gap: 10px;
}

.cta {
  appearance: none;
  width: 100%;
  min-width: 210px;
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  padding: 0 24px;
  background: var(--gold);
  color: var(--ink);
  font-size: 20px;
  font-weight: 850;
  touch-action: manipulation;
  transition: transform 0.06s ease, filter 0.12s ease;
}

.cta.secondary {
  background: #7fd1b2;
  font-size: 18px;
}

.cta:active {
  transform: scale(0.96);
  filter: brightness(1.08);
}

#commands {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  flex: 0 0 auto;
  padding-top: 10px;
}

.command {
  appearance: none;
  min-width: 0;
  min-height: 56px;
  border: 1px solid rgba(243, 234, 216, 0.18);
  border-radius: 8px;
  padding: 6px 5px;
  background: #22313b;
  color: var(--paper);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.24);
  touch-action: manipulation;
  transition: transform 0.06s ease, filter 0.12s ease, background-color 0.12s ease;
}

.command span:not(.glyph) {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--paper);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #c9d6c4;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command:active {
  transform: scale(0.96);
  filter: brightness(1.12);
}

.command:disabled {
  opacity: 0.48;
}

.command.resource {
  background: #243d36;
}

.command.strong {
  background: #3a354c;
}

.glyph {
  display: block;
  width: 17px;
  height: 17px;
  margin: 0 auto 4px;
  border-radius: 50%;
}

.glyph.food {
  background: var(--ember);
}

.glyph.wood {
  border-radius: 4px;
  background: var(--field);
}

.glyph.gold {
  background: var(--gold);
}

.glyph.archer {
  background: var(--water);
}

.glyph.soldier {
  border-radius: 5px;
  background: #bfc8d2;
}

.glyph.build {
  background: linear-gradient(135deg, #7fd1b2 0%, var(--gold) 100%);
}

#toast {
  position: absolute;
  left: 50%;
  bottom: calc(max(10px, var(--safe-bottom)) + 154px);
  z-index: 10;
  width: min(288px, calc(100% - 40px));
  min-height: 44px;
  transform: translateX(-50%);
  border: 1px solid rgba(243, 234, 216, 0.2);
  border-radius: 8px;
  padding: 11px 14px;
  background: var(--panel);
  color: var(--paper);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

#toast[hidden] {
  display: none;
}

@media (max-height: 700px) {
  #hud {
    min-height: 48px;
    padding-bottom: 6px;
  }

  .stat span:last-child {
    font-size: 19px;
  }

  .command {
    min-height: 52px;
  }
}
