body, html { 
  margin: 0; 
  padding: 0; 
  overflow: hidden;
  height: 100%;
  font-family: Arial, sans-serif;
  overscroll-behavior: none;
  background: var(--terrain-background, #0a2615);
}

body {
  position: fixed;
  inset: 0;
  background: var(--terrain-background, #0a2615);
}

#appViewport {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 360px;
  height: 640px;
  overflow: hidden;
  isolation: isolate;
  background: var(--terrain-background, #0a2615);
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  transform-origin: center;
}

button,
input,
textarea {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
canvas:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

h1 {display:none;}
/* Title Screen */
#titleScreen {
  position: relative;
  width: 100%;
  min-height: 100%;
  box-sizing: border-box;
  background: url('./assets/title-screen.jpg') center center;
  background-size: cover;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 100;
}

#companyName {
  color: #333;
  font-size: 2em;
  margin-top: 2vh;
  letter-spacing: 0.5em;
  text-transform: uppercase;
}

#gameIcon {
  width: 88%;
  max-width: 140px;
  margin: 10px auto;
}

#modeIcons {
  display: flex;
  justify-content: center;
  gap: 10px;
  width: 90%;
  max-width: 280px;
  margin: 10px auto;
}
.title-page { width:100%; display:flex; flex-direction:column; align-items:center; gap:14px; min-height:0; }
.title-page[hidden] { display:none; }
.campaign-tabs [hidden],.chronicle-list[hidden],#expressLevelList[hidden],#armyLevelList[hidden],#chronicleZoomOut[hidden]{display:none!important}
.game-choices { display:flex; align-items:center; justify-content:center; gap:16px; width:100%; }
.game-choice { width:140px; padding:0; border:0; background:transparent; cursor:pointer; color:#f4edc9; }
.game-choice img { display:block; width:100%; }
.game-choice:focus-visible, .title-back:focus-visible, .level-card:focus-visible { outline:3px solid #fff0a6; outline-offset:4px; }
.army-brand { width:140px; height:140px; box-sizing:border-box; border:3px solid #a9bc7b; border-radius:28px; background:#43543b; color:#f4edc9; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.army-brand span { font-size:48px; line-height:52px; }
.army-brand strong { font-size:25px; }
.army-brand small { font-size:14px; letter-spacing:2px; }
.title-back { align-self:flex-start; background:transparent; border:0; font-size:28px; color:#fff4ce; min-width:44px; min-height:44px; cursor:pointer; }
#armyPage h2, #expressPage h2 { margin:0; font-size:18px; color:#fff4ce; }
.army-levels { width:100%; max-height:250px; overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:#9aad78 transparent; padding-right:4px; box-sizing:border-box; }
.campaign-tabs{display:flex;gap:8px;width:100%;margin:0 0 8px}.campaign-tabs button{flex:1;border:1px solid #a4b47e;border-radius:7px;padding:7px;background:#294d35;color:#fff4d0}.campaign-tabs [aria-selected=true]{background:#596943}
.chronicle-card{display:flex;flex-direction:column;gap:9px;width:100%;margin:0 0 8px;padding:12px;background:#eee4cc;color:#231f18;border:1px solid #92876d;border-radius:3px;text-align:left;cursor:pointer}.chronicle-flag{font:900 20px "News Playfair",Georgia,serif;border-block:1px solid;padding-block:5px;width:100%;text-align:center}.chronicle-card span{font:400 20px "News Anton",Impact,serif}
#chronicleReader{position:fixed;inset:auto;left:50%;top:50%;margin:0;width:360px;height:640px;max-width:none;max-height:none;box-sizing:border-box;transform:translate(-50%,-50%);transform-origin:center;padding:0;border:0;background:#19231d;overflow:hidden}#chronicleReader::backdrop{background:#000d}
#chronicleCanvas{display:block;width:100%;height:100%;touch-action:none}
#chronicleClose,#chronicleZoomOut{position:absolute;top:8px;width:32px;height:32px;padding:3px;border:1px solid #6e624b;border-radius:50%;background:#eee4cce8;color:#231f18;cursor:pointer}#chronicleClose{right:8px;font-size:24px;line-height:24px}#chronicleZoomOut{left:8px}
@font-face{font-family:"News Anton";src:url('assets/fonts/newspapers/Anton-Regular.ttf') format('truetype');font-weight:400;font-display:swap}
@font-face{font-family:"News Oswald";src:url('assets/fonts/newspapers/Oswald-Variable.ttf') format('truetype');font-weight:200 700;font-display:swap}
@font-face{font-family:"News Playfair";src:url('assets/fonts/newspapers/PlayfairDisplay-Variable.ttf') format('truetype');font-weight:400 900;font-display:swap}
@font-face{font-family:"News Playfair";src:url('assets/fonts/newspapers/PlayfairDisplay-Italic-Variable.ttf') format('truetype');font-weight:400 900;font-style:italic;font-display:swap}
.army-levels::-webkit-scrollbar { width:6px; }
.army-levels::-webkit-scrollbar-track { background:transparent; }
.army-levels::-webkit-scrollbar-thumb { background:#9aad78; border-radius:8px; }
.army-levels::-webkit-scrollbar-thumb:hover { background:#c1cf9e; }
.army-levels::-webkit-scrollbar-button { display:none; width:0; height:0; }
#armyCameraHome{position:absolute;right:0;bottom:100%;width:32px;height:32px;margin-bottom:6px;padding:0;border:1px solid #a5b87e;border-radius:50%;background:#183d2bcc;color:#fff4ce;font-size:23px;cursor:pointer}
.level-card { display:block; box-sizing:border-box; width:100%; padding:13px 16px; margin:6px 0; text-align:left; font-size:16px; border:1px solid #a5b87e; border-radius:10px; background:#314935; color:#fff4ce; cursor:pointer; }
#armyLibraryStatus, #expressLibraryStatus { color:#fff4ce; font-size:13px; }
.modeButton[hidden], .level-card[hidden] { display:none; }

.modeButton {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
}

.modeButton:hover,
.modeButton:focus-visible {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.modeIcon {
  display: block;
  width: 100%;
  max-width: 60px;
  height: auto;
  margin: auto;
}

.armyModeButton { background: #43543b; border-color: #99ad76; color: #f1eccc; }
.armyModeButton span { display: block; font-size: 27px; line-height: 32px; }
.armyModeButton strong { display: block; font-size: 12px; }
#armyControls { position: absolute; bottom: max(8px, env(safe-area-inset-bottom)); left: 12px; right: 12px; z-index: 10;
  display:flex;flex-direction:column;gap:4px;
  text-align: center; color: #eef4df; font-size: 11px; pointer-events: none; }
#armyControls[hidden] { display: none; }
#armyTypeButtons{display:flex;justify-content:center;gap:10px;pointer-events:auto;margin:0;order:2}
.ant-type-control.flying{background:#ed50cf}
.ant-type-control{width:42px;height:42px;padding:7px;border:2px solid #23372c;border-radius:50%;color:#152019;cursor:pointer;box-sizing:border-box}
.ant-type-control svg{display:block;width:100%;height:100%;pointer-events:none}
.ant-type-control.black{background:#a4aaa5}.ant-type-control.acid{background:#81e54b}.ant-type-control.spark{background:#50e5f5}.ant-type-control.fire{background:#ed5146}.ant-type-control.heavy{background:#f59b38}.ant-type-control.all{background:#fff}
.ant-type-control:disabled{opacity:.35;cursor:default}
.ant-type-control[hidden],.army-queue-item[hidden],.queue-cancel[hidden]{display:none}
#armyQueue{display:flex;justify-content:center;gap:2px;min-height:0;margin:0;pointer-events:auto;order:1}
.army-queue-item{position:relative;width:38px;height:38px;padding:0;border:0;background:#12281e;border-radius:50%;cursor:pointer}
.army-queue-item svg{display:block;width:100%;height:100%;pointer-events:none}
.queue-track,.queue-timer{fill:none;stroke:currentColor;stroke-width:2}
.queue-track{opacity:.25}.queue-timer{stroke-dasharray:100;transform:rotate(-90deg);transform-origin:20px 20px}
.queue-cancel{position:absolute;inset:0;background:#18221ce8;color:white;border:1px solid #ef766c;border-radius:50%;font-size:28px;line-height:34px}
#armyHud{position:absolute;top:44px;left:50%;transform:translateX(-50%);display:flex;gap:8px;z-index:10;pointer-events:none;color:#eef4df;font-size:12px;font-weight:bold}
#armyHud[hidden]{display:none}
.army-hud-counter{display:inline-flex;align-items:center;gap:4px;background:#10271c70;border-radius:4px;padding:3px 6px;min-width:32px}
.army-hud-counter svg{width:18px;height:20px;display:block;color:#eef4df}
.army-target-icon{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.8;flex-shrink:0}
.army-victory-panel { width: min(320px, calc(100vw - 40px)); box-sizing: border-box;
  border: 2px solid #b9d483; background: #1e3026; }
.army-victory-panel h2 { color: #d5ff80; font-size: 1.6em; }
.army-victory-panel .dialog-buttons { flex-direction: column; }
.army-victory-panel .dialog-button { min-height: 44px; }
.army-victory-panel .primary { background: #d5ff80; color: #193020; }

#optionsButton {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid white;
  border-radius: 15px;
  color: white;
  font-size: 0.875rem;
  padding: 10px 20px;
  margin-top: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  display: flex;
  align-items: center;
  gap: 10px;
}

#optionsButton:hover {
  background: rgba(255, 255, 255, 0.2);
}

#titleFullscreenBtn {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid white;
  border-radius: 15px;
  color: white;
  font-size: 16px;
  padding: 6px;
  width: 36px;
  height: 36px;
  box-sizing: border-box;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 101;
}

#titleFullscreenBtn:hover {
  background: rgba(255, 255, 255, 0.2);
}

#fullscreenBtn::before, #titleFullscreenBtn::before {
   
  margin-right: 5px;
}

#toggleDesignBtn::before {
  
  margin-right: 5px;
}

#exitGameBtn {
  position: absolute;
  top: 10px;
  right: 230px;
  z-index: 10;
  padding: 8px 12px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid white;
  color: white;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s ease;
}

#exitGameBtn:hover {
  background: rgba(255, 255, 255, 0.3);
}

#exitGameBtn::before {
  margin-right: 5px;
}

/* Game Canvas and UI */
#gameScreen {
  display: none;
  position: absolute;
  inset: 0;
  width: 360px;
  height: 640px;
}

canvas { 
  background: var(--terrain-background, #0a2615);
  touch-action: none; 
  display: block; 
  width: 360px;
  height: 640px;
}

#score { 
  position: absolute; 
  top: 10px; 
  left: 10px; 
  font-size: 18px; 
}

#lineOutput { 
  width: 320px;
  height: 110px;
  font-family: monospace; 
  font-size: 12px;
  box-sizing: border-box;
  display: block;
  margin-top: 8px;
  resize: vertical;
}

#toggleDesignBtn {
  position: absolute;
 left:0;
  right: 10px;
  z-index: 10;
  padding: 8px 12px;
  font-size: 14px;
}

#fullscreenBtn {
  position: absolute;
  top: 10px;
  right: 120px;
  z-index: 10;
  padding: 8px 12px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid white;
  color: white;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s ease;
}

#fullscreenBtn:hover {
  background: rgba(255, 255, 255, 0.3);
}

#levelStatus[hidden]{display:none}
#armyBattlePanel[hidden],#battleReady[hidden],#battleLeave[hidden]{display:none!important}
#armyBattlePanel{font-size:13px;text-align:left;display:grid;gap:8px;width:100%;box-sizing:border-box;max-height:420px;overflow:auto}
#armyBattlePanel p,#armyBattlePanel h3{margin:0}#armyBattlePanel label{display:flex;align-items:center;gap:8px}
#armyBattlePanel input,#armyBattlePanel select{min-width:0;flex:1;padding:8px;background:#182b22;color:#fff4d0;border:1px solid #a4b47e;border-radius:5px}
#armyBattlePanel button{padding:8px;border-radius:5px;background:#294d35;color:#fff4d0;border:1px solid #a4b47e}
#battleDialog{position:fixed;width:360px;height:640px;max-width:none;max-height:none;padding:0;margin:0;border:0;overflow:hidden;background:#101d15;color:white;box-sizing:border-box}
#battleDialog::backdrop{background:#07100cf2}#battleCanvas{width:360px;height:640px;display:block;touch-action:none}
.battle-top{position:absolute;top:8px;left:8px;right:8px;display:flex;align-items:center;gap:6px;pointer-events:none;font-size:12px}
.battle-top button,.battle-bottom button{pointer-events:auto;background:#182b22dd;color:white;border:1px solid #b6c59b;border-radius:6px;padding:7px;cursor:pointer}
#battleStatus{flex:1;text-align:center;background:#182b22dd;padding:6px;border-radius:5px}
.battle-bottom{position:absolute;bottom:8px;left:8px;right:8px;display:grid;gap:5px}
#battleBuild,#battleQueue{display:flex;justify-content:center;gap:4px;flex-wrap:wrap}
#battleBuild button{width:48px;padding:5px 2px;font-size:9px}#battleBuild svg{display:block;width:24px;height:26px;margin:auto}
#battleQueue button{font-size:10px;padding:4px}.battle-bottom button:disabled{opacity:.4;cursor:default}
