@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;900&family=Inter:wght@600;800&display=swap");

:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  background: #17110e;
}

* { box-sizing: border-box; }

html,
body,
#romeGame {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #17110e;
  color: #fff8e8;
  user-select: none;
}

button,
a { font: inherit; }

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

#romeCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #b86a3c;
  touch-action: none;
}

.back-portal {
  position: fixed;
  z-index: 50;
  top: 18px;
  left: 18px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  border: 1px solid rgba(255, 233, 181, 0.42);
  border-radius: 5px;
  background: rgba(35, 22, 16, 0.82);
  color: #f7d282;
  font-family: Cinzel, serif;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  backdrop-filter: blur(8px);
}

.fight-hud {
  position: fixed;
  z-index: 10;
  top: 18px;
  left: 50%;
  width: min(880px, calc(100% - 210px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 92px 1fr;
  gap: 14px;
  align-items: start;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease;
}

body.fighting .fight-hud { opacity: 1; }

.fighter-status {
  min-width: 0;
  padding: 9px 12px 11px;
  border: 1px solid rgba(255, 218, 144, 0.4);
  border-radius: 5px;
  background: rgba(28, 18, 14, 0.84);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(7px);
}

.fighter-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  font-family: Cinzel, serif;
}

.fighter-heading strong {
  overflow: hidden;
  color: #fff5d9;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fighter-heading span {
  color: #d5ae70;
  font-size: 9px;
  font-weight: 900;
}

.enemy-status .fighter-heading { flex-direction: row-reverse; }

.health-track,
.stamina-track {
  overflow: hidden;
  width: 100%;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.health-track {
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.45);
}

.health-track i,
.stamina-track i {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left;
  transition: width 220ms ease;
}

.health-track i { background: linear-gradient(90deg, #8f191d, #e44436 60%, #ffbd65); }
.stamina-track { height: 4px; margin-top: 5px; }
.stamina-track i { background: #e9c55e; }
.enemy-status .health-track i,
.enemy-status .stamina-track i { margin-left: auto; }

.round-status {
  min-height: 74px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50% 50% 8px 8px;
  background: #7c201f;
  box-shadow: inset 0 0 0 2px #d8a849, 0 8px 28px rgba(0, 0, 0, 0.35);
  font-family: Cinzel, serif;
}

.round-status span,
.round-status small { color: #f1c96c; font-size: 8px; font-weight: 900; }
.round-status strong { color: #fff8df; font-size: 28px; line-height: 1; }

.start-screen,
.result-screen {
  position: fixed;
  z-index: 15;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 70px 24px 36px;
  text-align: center;
  background: linear-gradient(90deg, rgba(18, 10, 7, 0.88), rgba(18, 10, 7, 0.18) 50%, rgba(18, 10, 7, 0.88));
}

.start-screen {
  display: block;
  overflow-y: auto;
  padding: 20px clamp(24px, 4vw, 58px) 22px;
  text-align: left;
  background: linear-gradient(90deg, rgba(18, 10, 7, 0.94) 0, rgba(18, 10, 7, 0.58) 34%, rgba(18, 10, 7, 0.08) 56%, rgba(18, 10, 7, 0.82) 100%);
}

.start-screen h1 {
  font-size: clamp(30px, 4vw, 52px);
  line-height: 0.92;
}

.result-screen[hidden] { display: none; }
.start-screen[hidden] { display: none; }

.roman-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  margin: 0;
  border: 2px solid #d9a74c;
  border-radius: 50%;
  color: #f6d58b;
  font-family: Cinzel, serif;
  font-size: 15px;
  font-weight: 900;
  box-shadow: inset 0 0 0 6px rgba(138, 39, 31, 0.62), 0 0 42px rgba(240, 171, 76, 0.22);
}

.career-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1440px;
  margin: 0 auto;
  padding-left: 90px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(238, 209, 153, 0.22);
}

.career-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.career-brand .eyebrow { margin-bottom: 4px; }

.denarii-balance {
  display: grid;
  grid-template-columns: 38px auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  min-width: 154px;
  padding: 9px 12px;
  border-left: 2px solid #d3a74e;
  background: rgba(27, 18, 14, 0.72);
}

.denarii-balance i {
  grid-row: 1 / span 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid #f0cf79;
  border-radius: 50%;
  background: #a87525;
  color: #fff0bd;
  font-family: Cinzel, serif;
  font-size: 14px;
  font-style: normal;
  font-weight: 900;
  box-shadow: inset 0 0 0 3px #c99c3f;
}

.denarii-balance span {
  color: #cbb995;
  font-size: 9px;
  font-weight: 900;
}

.denarii-balance strong {
  color: #ffe6a0;
  font-family: Cinzel, serif;
  font-size: 20px;
}

.career-content {
  width: 100%;
  max-width: 1440px;
  min-height: min(560px, calc(100vh - 160px));
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(80px, 1fr) minmax(410px, 520px);
  gap: clamp(18px, 3vw, 44px);
  align-items: end;
  margin: 0 auto;
  padding: 24px 0 8px;
}

.gladiator-identity {
  grid-column: 1;
  align-self: center;
  padding: 22px 0;
}

.section-kicker {
  margin: 0 0 8px;
  color: #dcb35e;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.6px;
}

.gladiator-identity > label {
  display: block;
  margin-bottom: 8px;
  color: #e9dcc4;
  font-family: Cinzel, serif;
  font-size: 13px;
  font-weight: 700;
}

.name-field {
  position: relative;
  margin-bottom: 20px;
}

.name-field input {
  width: 100%;
  height: 52px;
  border: 1px solid rgba(239, 206, 139, 0.52);
  border-radius: 4px;
  padding: 0 74px 0 14px;
  background: rgba(28, 18, 14, 0.84);
  color: #fff2d1;
  font-family: Cinzel, serif;
  font-size: 20px;
  font-weight: 900;
  outline: none;
}

.name-field input:focus { border-color: #f0c65e; box-shadow: 0 0 0 3px rgba(240, 198, 94, 0.14); }

.name-field span {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: #7dd79c;
  font-size: 9px;
  font-weight: 900;
  opacity: 0;
  transition: opacity 160ms;
}

.name-field span.show { opacity: 1; }

.loadout-summary {
  border-top: 1px solid rgba(238, 209, 153, 0.2);
  border-bottom: 1px solid rgba(238, 209, 153, 0.2);
}

.loadout-summary > span {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  color: #a99a82;
  font-size: 9px;
  font-weight: 900;
}

.loadout-summary > span + span { border-top: 1px solid rgba(238, 209, 153, 0.1); }
.loadout-summary strong { color: #f4dfb1; font-size: 11px; text-align: right; }

.gladiator-identity #startFight {
  width: 100%;
  margin-top: 20px;
}

.armory-panel {
  grid-column: 3;
  align-self: end;
  min-width: 0;
  padding: 20px 0 4px 24px;
  border-left: 1px solid rgba(238, 209, 153, 0.25);
  background: linear-gradient(90deg, rgba(30, 20, 15, 0.75), rgba(20, 14, 11, 0.92));
}

.armory-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding-right: 14px;
}

.armory-heading h2 {
  font-size: 30px;
  text-shadow: none;
}

.armory-tabs {
  display: flex;
  gap: 3px;
}

.armory-tabs button {
  min-height: 31px;
  padding: 0 9px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #aa9c87;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.armory-tabs button.active {
  border-bottom-color: #e1b454;
  color: #ffe6a0;
}

.shop-items {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-right: 14px;
}

.shop-item {
  min-width: 0;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  padding: 11px;
  border: 1px solid rgba(238, 209, 153, 0.16);
  border-radius: 5px;
  background: rgba(15, 12, 10, 0.7);
}

.item-visual {
  position: relative;
  height: 66px;
  margin-bottom: 10px;
  overflow: hidden;
  border-radius: 3px;
  background: #30201a;
  background: radial-gradient(circle, color-mix(in srgb, var(--item-color) 55%, white), var(--item-color) 35%, #211713 70%);
}

.item-visual::before {
  position: absolute;
  inset: 13px 28%;
  border: 3px solid rgba(255, 241, 207, 0.72);
  border-radius: 50% 50% 20% 20%;
  background: var(--item-color);
  content: "";
}

.shop-item[data-category="sword"] .item-visual::before {
  inset: 6px 46%;
  border-width: 1px;
  border-radius: 2px;
  transform: rotate(27deg);
}

.shop-item[data-category="shield"] .item-visual::before {
  inset: 9px 34%;
  border-radius: 48%;
}

.shop-item h3 {
  min-height: 30px;
  margin: 0 0 3px;
  color: #f6e8c8;
  font-family: Cinzel, serif;
  font-size: 11px;
  line-height: 1.25;
}

.shop-item p {
  flex: 1;
  margin: 0 0 8px;
  color: #9e927f;
  font-size: 9px;
  line-height: 1.35;
}

.shop-item button {
  min-height: 31px;
  border: 1px solid rgba(238, 209, 153, 0.32);
  border-radius: 4px;
  background: #70302a;
  color: #fff0c9;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
}

.shop-item button.owned { background: #665020; }
.shop-item button.equipped { background: #355b42; color: #b8f0c9; }
.shop-item button:disabled { cursor: default; opacity: 1; }
.shop-message { min-height: 16px; margin: 8px 14px 0 0; color: #e9c86e; font-size: 10px; text-align: right; }

.eyebrow,
.result-screen p:first-child {
  margin: 0 0 7px;
  color: #e1b662;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
}

h1,
h2 {
  margin: 0;
  color: #fff3cf;
  font-family: Cinzel, serif;
  font-size: clamp(52px, 8vw, 112px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.9;
  text-shadow: 0 5px 0 #67231d, 0 14px 30px rgba(0, 0, 0, 0.55);
}

h2 { font-size: clamp(48px, 7vw, 88px); }

.intro,
#resultCopy {
  max-width: 560px;
  margin: 20px 0 27px;
  color: #e8d9bd;
  font-size: clamp(14px, 1.6vw, 18px);
  line-height: 1.5;
}

#startFight,
#continueFight {
  min-height: 54px;
  padding: 0 30px;
  border: 1px solid #f1cf77;
  border-radius: 5px;
  background: #9e2c24;
  color: #fff3cf;
  font-family: Cinzel, serif;
  font-size: 15px;
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(67, 12, 12, 0.34), 0 12px 30px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

#startFight:hover,
#continueFight:hover { background: #bd3a2d; transform: translateY(-2px); }

.start-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  max-width: 620px;
  gap: 17px;
  margin-top: 24px;
  color: #cabca3;
  font-size: 11px;
  font-weight: 800;
}

kbd {
  padding: 4px 7px;
  border: 1px solid rgba(255, 231, 180, 0.35);
  border-radius: 3px;
  background: rgba(28, 18, 14, 0.78);
  color: #f4d278;
  font-family: inherit;
  font-size: 10px;
}

.desktop-controls {
  position: fixed;
  z-index: 9;
  bottom: 17px;
  left: 50%;
  display: flex;
  gap: 16px;
  transform: translateX(-50%);
  color: rgba(255, 244, 218, 0.8);
  font-size: 10px;
  font-weight: 900;
  opacity: 0;
  transition: opacity 300ms ease;
}

body.fighting .desktop-controls { opacity: 1; }

.combat-callout {
  position: fixed;
  z-index: 12;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -16px) scale(0.9);
  color: #ffe29b;
  font-family: Cinzel, serif;
  font-size: clamp(20px, 3vw, 36px);
  font-weight: 900;
  text-shadow: 0 3px 0 #5e1816, 0 8px 24px #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms, transform 160ms;
}

.combat-callout.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.mobile-controls { display: none; }

@media (max-width: 760px), (pointer: coarse) {
  .fight-hud {
    top: 66px;
    width: calc(100% - 18px);
    grid-template-columns: 1fr 58px 1fr;
    gap: 5px;
  }

  .fighter-status { padding: 7px; }
  .fighter-heading span { display: none; }
  .fighter-heading strong { font-size: 10px; }
  .round-status { min-height: 61px; }
  .round-status strong { font-size: 21px; }
  .desktop-controls { display: none; }
  .start-controls { display: none; }

  .mobile-controls {
    position: fixed;
    z-index: 11;
    right: 13px;
    bottom: 14px;
    left: 13px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms;
  }

  body.fighting .mobile-controls { opacity: 1; }
  .mobile-controls button { pointer-events: auto; touch-action: none; }

  .move-pad {
    width: 126px;
    display: grid;
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(2, 40px);
    gap: 3px;
  }

  .move-pad button,
  .action-pad button {
    border: 1px solid rgba(255, 236, 191, 0.38);
    border-radius: 50%;
    background: rgba(35, 22, 16, 0.7);
    color: #ffe2a0;
    font-size: 12px;
    font-weight: 900;
    backdrop-filter: blur(5px);
  }

  .move-pad button:nth-child(1) { grid-column: 2; }
  .move-pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
  .move-pad button:nth-child(3) { grid-column: 2; grid-row: 2; }
  .move-pad button:nth-child(4) { grid-column: 3; grid-row: 2; }

  .action-pad {
    display: grid;
    grid-template-columns: 54px 54px 66px;
    grid-template-rows: 45px 45px;
    gap: 5px;
  }

  .action-pad .attack-touch { grid-column: 3; grid-row: 1 / span 2; background: rgba(146, 34, 29, 0.82); }
  .action-pad .shield-touch { grid-column: 1; }
  .action-pad .dodge-touch { grid-column: 1; grid-row: 2; font-size: 9px; }
  .action-pad .heavy-touch { grid-column: 2; grid-row: 1; font-size: 9px; background: rgba(116, 58, 24, 0.82); }
  .action-pad .bash-touch { grid-column: 2; grid-row: 2; font-size: 9px; }
}

@media (max-width: 720px) {
  .start-screen {
    padding: 72px 16px 28px;
    text-align: left;
    background: rgba(18, 10, 7, 0.9);
  }

  .career-header { align-items: flex-start; }
  .career-header { padding-left: 0; }
  .career-brand { align-items: flex-start; }
  .career-brand .roman-mark { width: 46px; height: 46px; font-size: 11px; }
  .start-screen h1 { font-size: 28px; }
  .denarii-balance { min-width: 118px; }
  .career-content { display: block; min-height: 0; padding-top: 10px; }
  .gladiator-identity { padding: 14px 0 20px; }
  .armory-panel { margin-top: 8px; padding-left: 14px; }
  .armory-heading { align-items: flex-start; flex-direction: column; }
  .shop-items { grid-template-columns: repeat(3, minmax(130px, 1fr)); overflow-x: auto; padding-bottom: 6px; }
  .shop-item { min-height: 176px; }
  .start-controls { justify-content: flex-start; }
}

@media (max-height: 560px) {
  .roman-mark { display: none; }
  .start-screen { padding-top: 50px; }
  .intro { margin: 10px 0 15px; }
  .start-controls { margin-top: 13px; }
}
