@import url("https://fonts.googleapis.com/css2?family=Black+Ops+One&display=swap");

:root {
  --gold: #f3c95d;
  --cyan: #50e8ff;
  --violet: #a94cff;
  --ink: #050812;
  --panel: rgba(6, 10, 22, .9);
  --line: rgba(100, 222, 255, .28);
  --danger: #ff4f67;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body, #game {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  color: #f5f0e4;
  background: var(--ink);
  font-family: "Courier New", monospace;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

button, select, input { font: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

h1, h2, h3, .identity strong, .mission-panel strong {
  font-family: "Black Ops One", Impact, "Arial Black", sans-serif;
  font-weight: 400;
  text-transform: uppercase;
}

#game { position: relative; isolation: isolate; }

#game::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    radial-gradient(circle at center, transparent 58%, rgba(0,0,0,.42));
  background-size: 100% 4px, 100% 100%;
  mix-blend-mode: screen;
  opacity: .55;
}

#glCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #050812;
  outline: 0;
}

.top-hud,
.mission-panel,
.location-panel,
.boss-panel,
.interaction,
.dialog,
.desktop-controls,
.combat-message,
.save-message,
.objective-marker,
.touch-controls {
  position: absolute;
  z-index: 6;
}

.top-hud {
  top: max(14px, env(safe-area-inset-top));
  left: 18px;
  right: 18px;
  display: grid;
  grid-template-columns: 52px minmax(190px, auto) minmax(230px, 1fr) repeat(3, 44px);
  align-items: center;
  gap: 11px;
  min-height: 66px;
  padding: 7px 10px;
  border: 1px solid rgba(125, 139, 190, .5);
  clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 15px 100%, 0 calc(100% - 15px));
  background: linear-gradient(90deg, rgba(5,8,18,.96), rgba(15,17,35,.82));
  box-shadow: 0 12px 40px rgba(0,0,0,.42), inset 0 -2px rgba(111,57,165,.22);
  backdrop-filter: blur(9px);
}

.top-hud > img { width: 48px; height: 48px; object-fit: cover; border-radius: 50%; }
.identity { min-width: 0; display: flex; flex-direction: column; }
.identity span { color: var(--cyan); font-size: 8px; letter-spacing: 2.5px; }
.identity strong { overflow: hidden; color: var(--gold); font-size: clamp(12px, 1.35vw, 18px); text-overflow: ellipsis; white-space: nowrap; }

.status-block { display: grid; grid-template-columns: minmax(100px, 1fr); gap: 3px; padding: 0 10px; }
.status-line, .status-block small { display: flex; justify-content: space-between; gap: 12px; font-size: 8px; letter-spacing: 1px; }
.status-line b, .status-line em { color: var(--gold); font-style: normal; }
.status-block small { color: #8f9ab7; }
.meter { height: 7px; overflow: hidden; border: 1px solid rgba(137,153,205,.45); background: #1b2034; }
.meter i { display: block; width: 100%; height: 100%; transition: width .18s ease; }
.health i { background: linear-gradient(90deg, #b51f3a, #ff6476); box-shadow: 0 0 12px rgba(255,71,95,.65); }
.stamina i { background: linear-gradient(90deg, #0f91ae, #5deaff); box-shadow: 0 0 10px rgba(66,225,255,.55); }

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(128,144,196,.58);
  color: #efe8dc;
  background: rgba(22,27,51,.9);
  font-size: 18px;
}
.icon-button:hover, .icon-button:focus-visible { color: #10131e; background: var(--gold); outline: 0; }

.mission-panel {
  top: 96px;
  right: 18px;
  width: min(340px, 36vw);
  padding: 13px 15px 14px;
  border-left: 3px solid var(--gold);
  background: linear-gradient(100deg, rgba(8,11,24,.94), rgba(13,15,30,.78));
  box-shadow: 0 14px 34px rgba(0,0,0,.42);
  backdrop-filter: blur(8px);
}
.mission-panel small { color: var(--gold); font-size: 8px; letter-spacing: 2px; }
.mission-panel strong { display: block; margin: 5px 0; font-size: clamp(13px, 1.4vw, 18px); }
.mission-panel p { margin: 0; color: #c2c8d7; font-size: 10px; line-height: 1.5; }
.objective-progress { margin-top: 7px; color: var(--cyan); font-size: 9px; letter-spacing: 1px; }

.location-panel {
  top: 101px;
  left: 20px;
  padding-left: 11px;
  border-left: 3px solid var(--cyan);
  text-shadow: 0 2px 6px #000;
}
.location-panel span { display: block; color: var(--cyan); font-size: 9px; letter-spacing: 2px; }
.location-panel strong { font-size: 11px; }

.boss-panel {
  top: 94px;
  left: 50%;
  width: min(460px, 42vw);
  padding: 9px 12px;
  text-align: center;
  background: rgba(8,8,18,.88);
  transform: translateX(-50%);
  clip-path: polygon(18px 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 18px 100%, 0 50%);
}
.boss-panel small { color: #ff9aa7; letter-spacing: 2px; }
.boss-meter { height: 9px; margin: 5px 18px 0; border: 1px solid rgba(255,91,112,.55); background: #25131c; }
.boss-meter i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #8b1331, #ff5570); transition: width .2s; }

.crosshair { left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%,-50%); opacity: .72; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: #d9fbff; box-shadow: 0 0 7px var(--cyan); }
.crosshair::before { left: 8px; top: 0; width: 2px; height: 18px; }
.crosshair::after { left: 0; top: 8px; width: 18px; height: 2px; }

.objective-marker {
  left: 50%;
  top: 28%;
  display: grid;
  justify-items: center;
  color: var(--cyan);
  font-size: 9px;
  text-shadow: 0 2px 5px #000;
  transform: translate(-50%,-50%);
  pointer-events: none;
}
.objective-marker i { width: 13px; height: 13px; margin-bottom: 4px; border: 2px solid currentColor; transform: rotate(45deg); box-shadow: 0 0 12px currentColor; }

.interaction {
  left: 50%;
  bottom: 112px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  border: 1px solid rgba(243,201,93,.38);
  color: var(--gold);
  background: rgba(4,7,15,.9);
  transform: translateX(-50%);
  font-size: 10px;
}
kbd { padding: 3px 6px; color: #10131e; background: #f2eddf; font-weight: bold; }

.dialog {
  z-index: 14;
  left: max(5%, 20px);
  right: max(5%, 20px);
  bottom: max(6%, calc(20px + var(--safe-bottom)));
  min-height: 132px;
  padding: 31px 150px 20px 24px;
  border: 1px solid rgba(137,158,220,.72);
  background: linear-gradient(105deg, rgba(5,9,20,.98), rgba(18,17,38,.95));
  box-shadow: 0 0 48px rgba(0,0,0,.75), inset 0 0 40px rgba(95,48,150,.12);
}
.dialog > strong { position: absolute; top: -15px; left: 18px; padding: 8px 14px; color: #11131c; background: var(--gold); }
.dialog p { margin: 0; color: #e2deD5; line-height: 1.65; }
.dialog button { position: absolute; right: 18px; bottom: 17px; padding: 10px 13px; border: 1px solid rgba(116,215,234,.45); color: var(--cyan); background: rgba(13,23,39,.88); }

.combat-message { left: 50%; top: 25%; color: #fff; font-size: clamp(16px, 2vw, 25px); font-weight: bold; text-shadow: 0 3px 10px #000; transform: translateX(-50%); opacity: 0; transition: opacity .18s; pointer-events: none; }
.save-message { right: 18px; bottom: 74px; padding: 8px 12px; color: var(--cyan); background: rgba(5,10,19,.78); font-size: 8px; letter-spacing: 1px; opacity: 0; transition: opacity .25s; pointer-events: none; }

.desktop-controls {
  left: 50%;
  bottom: 16px;
  display: flex;
  gap: 13px;
  max-width: calc(100% - 24px);
  padding: 8px 12px;
  color: #969eb6;
  background: rgba(5,8,17,.77);
  transform: translateX(-50%);
  font-size: 8px;
  white-space: nowrap;
}

.loading-screen, .menu-screen, .overlay-panel, .chapter-screen {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(98,42,167,.3), transparent 34%),
    linear-gradient(rgba(4,7,16,.7), rgba(4,7,16,.96));
  backdrop-filter: blur(7px);
}

.loading-screen { align-content: center; }
.loading-screen img { width: 130px; height: 130px; object-fit: cover; border-radius: 50%; box-shadow: 0 0 50px rgba(140,70,220,.5); }
.loading-screen small, .panel-card > small, .chapter-screen > small { margin-top: 15px; color: var(--cyan); font-size: 9px; letter-spacing: 3px; }
.loading-screen h1, .menu-card h1 { margin: 10px 0 18px; font-size: clamp(35px, 6.2vw, 78px); line-height: .9; text-shadow: 0 5px 0 #111426, 0 0 30px rgba(129,67,204,.55); }
.loading-screen h1 span, .menu-card h1 span { display: block; color: #b766ff; }
.loading-track { width: min(500px, 80vw); height: 10px; padding: 2px; border: 1px solid rgba(95,214,240,.5); background: #11172a; }
.loading-track i { display: block; width: 5%; height: 100%; background: linear-gradient(90deg, var(--violet), var(--cyan)); box-shadow: 0 0 15px var(--cyan); transition: width .3s; }
.loading-screen p { color: #9aa6c2; font-size: 9px; letter-spacing: 2px; }
.loading-retry {
  margin-top: 14px;
  padding: 12px 20px;
  border: 1px solid rgba(255, 101, 120, .8);
  color: #fff;
  background: rgba(105, 14, 31, .78);
  font: 700 12px "Courier New", monospace;
  letter-spacing: 1.4px;
  cursor: pointer;
}
.loading-retry:hover, .loading-retry:focus-visible { background: rgba(169, 23, 50, .92); }

.menu-card, .panel-card {
  width: min(720px, 94vw);
  max-height: min(92vh, 820px);
  overflow: auto;
  padding: 27px;
  border: 1px solid rgba(122,139,195,.52);
  clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
  background: linear-gradient(125deg, rgba(7,10,23,.97), rgba(19,17,39,.94));
  box-shadow: 0 25px 80px rgba(0,0,0,.55), inset 0 0 50px rgba(100,49,158,.1);
}
.menu-card > img { width: 118px; height: 118px; object-fit: cover; border-radius: 50%; box-shadow: 0 0 42px rgba(152,71,232,.5); }
.menu-card > p { margin: 12px 0 0; color: var(--gold); font-size: 9px; letter-spacing: 5px; }
.tagline { margin: 0 0 21px; color: var(--cyan); letter-spacing: 3px; }
.menu-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; width: min(480px, 100%); margin: 0 auto; }
.menu-actions button, .panel-card button, .chapter-screen button, .panel-card a {
  min-height: 45px;
  padding: 11px 15px;
  border: 1px solid rgba(126,143,196,.6);
  color: #eee9dd;
  background: rgba(24,29,54,.92);
  font-weight: bold;
  text-decoration: none;
}
.menu-actions button:hover, .panel-card button:hover, .chapter-screen button:hover, .panel-card a:hover,
.menu-actions button:focus-visible, .panel-card button:focus-visible, .chapter-screen button:focus-visible, .panel-card a:focus-visible { color: #10131d; background: var(--gold); outline: 0; }
.menu-actions .primary, .panel-card .primary, .chapter-screen .primary { color: #fff; border-color: #cc73ff; background: linear-gradient(135deg, #a82de0, #6722a5); box-shadow: 0 0 22px rgba(173,69,238,.35); }
.menu-actions button:disabled { cursor: not-allowed; opacity: .38; }
.menu-links { display: flex; justify-content: center; gap: 20px; margin: 17px 0 12px; }
.menu-links a, .chapter-screen a { color: #a5b3d4; font-size: 9px; text-decoration: none; }
.menu-links a:hover, .chapter-screen a:hover { color: var(--cyan); }
.menu-card > small { color: #7883a2; font-size: 8px; letter-spacing: 1px; }

.panel-card { display: grid; gap: 13px; text-align: left; }
.panel-card.compact { width: min(400px, 92vw); text-align: center; }
.panel-card h2 { margin: 0 0 4px; font-size: clamp(34px, 6vw, 68px); }
.panel-card label { display: grid; gap: 7px; color: #a9b4cd; font-size: 10px; letter-spacing: 1px; }
.panel-card select, .panel-card input[type="range"] { width: 100%; min-height: 42px; padding: 8px; border: 1px solid #4c5877; color: #f1ecdf; background: #0b1121; }
.panel-card .check-line { display: flex; align-items: center; gap: 9px; }
.panel-card .check-line input { width: 18px; height: 18px; accent-color: var(--violet); }
.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.control-grid { display: grid; grid-template-columns: minmax(150px, .8fr) 1fr; gap: 1px; background: rgba(119,139,187,.25); }
.control-grid > * { padding: 10px; background: #0a0e1b; }
.control-grid b { color: var(--cyan); }

.chapter-screen { align-content: center; }
.chapter-screen h2 { max-width: 900px; margin: 10px 0 8px; font-size: clamp(42px, 7vw, 96px); color: var(--gold); line-height: .92; text-shadow: 0 5px #141426; }
.chapter-screen p { color: #d1d3df; font-size: clamp(15px, 2vw, 21px); line-height: 1.7; }
.chapter-actions { display: flex; align-items: center; gap: 18px; }

.touch-controls { inset: 0; pointer-events: none; }
.move-pad, .look-pad, .touch-action { pointer-events: auto; touch-action: none; }
.move-pad {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(24px, calc(14px + var(--safe-bottom)));
  width: 126px;
  height: 126px;
  border: 1px solid rgba(85,225,255,.36);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(61,105,133,.2), rgba(5,9,19,.5));
}
.move-pad i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; border: 1px solid rgba(159,238,255,.6); border-radius: 50%; background: rgba(17,47,66,.7); transform: translate(-50%,-50%); box-shadow: 0 0 18px rgba(50,209,242,.25); }
.look-pad { position: absolute; right: 0; top: 20%; bottom: 0; width: 52%; }
.touch-action { position: absolute; display: grid; place-items: center; border: 1px solid rgba(210,170,255,.58); border-radius: 50%; color: #fff; background: rgba(73,28,112,.68); font-size: 8px; font-weight: bold; }
.touch-action.attack { right: max(20px, env(safe-area-inset-right)); bottom: max(30px, calc(20px + var(--safe-bottom))); width: 78px; height: 78px; }
.touch-action.dodge { right: max(106px, calc(86px + env(safe-area-inset-right))); bottom: max(22px, calc(12px + var(--safe-bottom))); width: 61px; height: 61px; }
.touch-action.interact { right: max(34px, env(safe-area-inset-right)); bottom: max(120px, calc(110px + var(--safe-bottom))); width: 57px; height: 57px; color: #11131d; border-color: rgba(252,221,132,.75); background: rgba(243,201,93,.9); }

noscript { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 30px; color: white; background: #050812; }

@media (max-width: 850px) {
  .top-hud { grid-template-columns: 42px minmax(0, 1fr) repeat(3, 38px); top: max(7px, env(safe-area-inset-top)); left: 7px; right: 7px; min-height: 54px; gap: 6px; }
  .top-hud > img { width: 38px; height: 38px; }
  .identity span { font-size: 6px; }
  .identity strong { font-size: 11px; }
  .status-block { position: absolute; top: 58px; left: 0; width: min(330px, 72vw); padding: 7px 9px; background: rgba(5,8,18,.8); }
  .icon-button { width: 36px; height: 36px; }
  .mission-panel { top: 125px; right: 7px; width: min(310px, 52vw); }
  .location-panel { top: 126px; left: 9px; max-width: 43vw; }
  .boss-panel { top: 82px; width: min(400px, 70vw); }
  .desktop-controls { display: none !important; }
  .interaction { bottom: 178px; }
  .dialog { left: 10px; right: 10px; bottom: max(12px, var(--safe-bottom)); min-height: 145px; padding: 29px 16px 56px; }
  .dialog button { right: 13px; bottom: 10px; }
  .menu-card, .panel-card { padding: 19px; }
  .menu-card > img { width: 90px; height: 90px; }
  .menu-card h1 { font-size: clamp(35px, 10vw, 66px); }
}

@media (max-width: 560px) {
  .top-hud { grid-template-columns: 38px minmax(0, 1fr) repeat(3, 34px); }
  .icon-button { width: 32px; height: 32px; padding: 0; font-size: 14px; }
  .identity strong { font-size: 9px; }
  .mission-panel { top: 116px; width: 55vw; padding: 10px; }
  .mission-panel p { font-size: 8px; }
  .location-panel { top: 117px; }
  .location-panel span { font-size: 7px; }
  .location-panel strong { font-size: 8px; }
  .boss-panel { top: 78px; width: 86vw; }
  .menu-actions { grid-template-columns: 1fr; }
  .menu-links { flex-direction: column; gap: 9px; }
  .tagline { font-size: 10px; }
  .control-grid { grid-template-columns: 1fr; }
  .panel-actions { grid-template-columns: 1fr; }
  .chapter-actions { flex-direction: column; }
  .objective-marker { top: 33%; }
}

@media (pointer: fine) {
  .touch-controls { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
