:root {
  --paper: #f5ead1;
  --paper-shadow: #e2d0aa;
  --ink: #2b251c;
  --line: #5a4d39;
  --blue: #4b7ef1;
  --blue-soft: #b0cafc;
  --red: #d75a55;
  --red-soft: #f3b1ab;
  --gold: #e0b449;
  --gold-soft: #f4df99;
  --panel: rgba(255, 248, 232, 0.9);
  --panel-strong: rgba(252, 241, 214, 0.96);
  --shadow: rgba(43, 37, 28, 0.18);
  --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 {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: "Marker Felt", "Comic Sans MS", "Bradley Hand", cursive;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.5), transparent 40%),
    linear-gradient(180deg, #efe1bb 0%, #ead5a2 100%);
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(0deg, transparent 23px, rgba(103, 85, 58, 0.2) 24px),
    linear-gradient(90deg, transparent 23px, rgba(103, 85, 58, 0.08) 24px);
  background-size: 24px 24px;
}

.app-shell {
  width: min(1380px, calc(100vw - 24px));
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  padding: 8px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}

.title-bar,
.game-shell,
.overlay-card,
.hud-card,
.side-panel,
.unit-guide-card,
.deployment-group,
.deploy-button {
  border: 3px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 10px 18px var(--shadow);
  position: relative;
}

.title-bar::after,
.game-shell::after,
.overlay-card::after,
.hud-card::after,
.side-panel::after,
.unit-guide-card::after,
.deployment-group::after,
.deploy-button::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px solid rgba(90, 77, 57, 0.28);
  border-radius: 16px;
  pointer-events: none;
}

.title-bar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  padding: 14px 20px;
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.86rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 0.95;
}

#overlayTitle {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
}

.subtitle {
  max-width: 440px;
  font-size: 0.98rem;
  line-height: 1.35;
  text-align: right;
}

.game-shell {
  min-height: 0;
  padding: 12px;
  background: var(--panel);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 272px;
  gap: 12px;
  overflow: hidden;
}

.map-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.battle-stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  position: relative;
}

.hud-row {
  display: grid;
  grid-template-columns: minmax(240px, 0.88fr) minmax(340px, 1.22fr) minmax(240px, 0.88fr);
  gap: 12px;
}

.hud-card {
  min-height: 76px;
  padding: 12px 14px;
  background: var(--panel-strong);
}

.hud-card h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.hud-lines {
  display: grid;
  gap: 4px;
  font-size: 0.98rem;
}

.hud-card-center {
  text-align: center;
  display: grid;
  place-items: center;
}

.canvas-frame {
  position: relative;
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(180deg, #f9f0d3 0%, #ebd6a4 100%);
}

.time-display {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 120px;
  padding: 8px 18px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 251, 241, 0.82);
  box-shadow: 0 8px 16px var(--shadow);
  text-align: center;
  font-size: 1.15rem;
  line-height: 1;
  z-index: 2;
  backdrop-filter: blur(4px);
}

.side-panel {
  min-height: 0;
  height: 100%;
  padding: 14px;
  background: var(--panel-strong);
  position: sticky;
  top: 0;
  overflow: hidden;
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.side-panel-close,
.unit-guide-toggle,
.side-panel-backdrop {
  display: none;
}

.side-panel-close,
.unit-guide-toggle {
  border: 2px solid var(--line);
  border-radius: 14px;
  font: inherit;
  color: var(--ink);
  background: linear-gradient(180deg, #fff7e3, #f3d987);
  box-shadow: 0 6px 12px rgba(43, 37, 28, 0.16);
}

.side-panel-close {
  padding: 6px 10px;
  font-size: 0.82rem;
}

.unit-guide-toggle {
  padding: 2px 2px;
  font-size: 0.9rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.06em;
}

.side-panel-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(36, 30, 23, 0.24);
  opacity: 0;
  pointer-events: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  aspect-ratio: 16 / 9;
}

button,
canvas {
  touch-action: manipulation;
}

.message-banner {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 2px;
  padding: 10px 16px;
  border-radius: 16px;
  background: rgba(255, 251, 241, 0.72);
  border: 2px solid rgba(90, 77, 57, 0.4);
  font-size: 0.95rem;
  backdrop-filter: blur(4px);
  z-index: 2;
  transition: opacity 160ms ease, transform 160ms ease;
}

.deployment-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.deployment-group {
  position: absolute;
  right: clamp(32px, 4vw, 56px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: rgba(255, 251, 241, 0.78);
  backdrop-filter: blur(6px);
  pointer-events: auto;
  transform: translateY(-50%);
}

.deployment-group::after {
  inset: 4px;
  border-radius: 18px;
}

.deployment-group[data-lane="top"] {
  top: 18%;
}

.deployment-group[data-lane="bottom"] {
  top: 81%;
}

.deployment-group[data-state="pushing"] {
  background: rgba(235, 247, 255, 0.8);
}

.deployment-group[data-state="threatened"] {
  background: rgba(255, 241, 237, 0.82);
}

.deployment-title {
  min-width: 42px;
  font-size: 0.74rem;
  line-height: 1.05;
  text-transform: uppercase;
}

.deploy-buttons,
.unit-guide {
  display: grid;
}

.deploy-buttons {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.unit-guide {
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
  height: calc(100% - 26px);
  align-content: stretch;
}

.deploy-button {
  width: 48px;
  min-width: 48px;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border: 2px solid rgba(90, 77, 57, 0.88);
  border-bottom-width: 4px;
  border-radius: 13px;
  font: inherit;
  padding: 6px 4px 5px;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, #fff8dc 0%, #f7e4ae 68%, #edcb78 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 2px 0 rgba(128, 96, 38, 0.72),
    0 7px 12px rgba(43, 37, 28, 0.16);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.deploy-button::after {
  content: none;
}

.deploy-button:hover:not(.is-disabled) {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 4px 0 rgba(128, 96, 38, 0.76),
    0 10px 16px rgba(43, 37, 28, 0.2);
}

.deploy-button:active:not(.is-disabled) {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 1px 0 rgba(128, 96, 38, 0.7),
    0 4px 7px rgba(43, 37, 28, 0.14);
}

.deploy-button.is-disabled {
  cursor: not-allowed;
  opacity: 0.66;
  background: linear-gradient(180deg, rgba(242, 235, 217, 0.98), rgba(221, 208, 176, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.66),
    0 2px 0 rgba(128, 96, 38, 0.38),
    0 4px 8px rgba(43, 37, 28, 0.12);
}

.deploy-button.is-disabled:hover {
  transform: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.66),
    0 2px 0 rgba(128, 96, 38, 0.38),
    0 4px 8px rgba(43, 37, 28, 0.12);
}

.unit-name {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.deploy-badge {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  margin: 0 auto 3px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  border: 0;
  color: var(--ink);
}

.deploy-badge svg,
.unit-icon svg {
  width: 17px;
  height: 17px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.deploy-note,
.unit-meta,
.unit-stats,
.unit-role,
.unit-matchup {
  font-size: 0.94rem;
  line-height: 1.3;
}

.deploy-note {
  font-size: 0.68rem;
  line-height: 1;
  color: rgba(43, 37, 28, 0.92);
}

.deploy-note:empty {
  display: none;
}

.unit-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.unit-meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.unit-guide-card {
  min-height: 0;
  padding: 8px 10px 10px;
  background: linear-gradient(180deg, rgba(255, 247, 223, 0.96), rgba(245, 228, 179, 0.98));
  display: grid;
  align-content: start;
  gap: 3px;
}

.unit-role {
  margin-bottom: 2px;
  color: rgba(43, 37, 28, 0.84);
}

.unit-name strong {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.unit-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(75, 126, 241, 0.12);
  border: 1px solid rgba(90, 77, 57, 0.22);
  color: var(--ink);
}

.unit-matchup + .unit-matchup {
  margin-top: 1px;
}

.unit-chip {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(90, 77, 57, 0.08);
  font-size: 0.8rem;
}

.unit-matchup {
  font-size: 0.82rem;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 40;
  background: rgba(36, 30, 23, 0.45);
  backdrop-filter: blur(6px);
}

.hidden {
  display: none;
}

.overlay-card {
  width: min(900px, calc(100vw - 32px));
  padding: 26px;
  background: rgba(254, 246, 225, 0.98);
}

.rotate-hint {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 14px);
  transform: translate(-50%, 12px);
  max-width: min(88vw, 320px);
  padding: 10px 14px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 248, 232, 0.96);
  box-shadow: 0 10px 18px var(--shadow);
  color: var(--ink);
  font-size: 0.92rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity 180ms ease, transform 180ms ease;
}

.rotate-hint.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.result-badge {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  border: 2px solid rgba(90, 77, 57, 0.28);
  background: rgba(255, 251, 241, 0.9);
}

.overlay[data-result="win"] .result-badge {
  color: #9f6a12;
  background: rgba(244, 223, 153, 0.45);
}

.overlay[data-result="lose"] .result-badge {
  color: #8c3b37;
  background: rgba(243, 177, 171, 0.36);
}

.result-badge svg {
  width: 30px;
  height: 30px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.overlay-subtitle {
  margin-top: 10px;
  font-size: 1rem;
  line-height: 1.4;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 20px;
}

.summary-card {
  padding: 16px;
  border: 2px solid rgba(90, 77, 57, 0.55);
  border-radius: 18px;
  background: rgba(255, 251, 241, 0.88);
}

.summary-card h3 {
  margin: 0 0 12px;
}

.summary-line {
  padding: 6px 0;
  border-bottom: 1px dashed rgba(90, 77, 57, 0.32);
  font-size: 0.95rem;
}

.summary-line-unit {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.summary-line-total {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
}

.summary-line:last-child {
  border-bottom: 0;
}

.summary-unit {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(90, 77, 57, 0.08);
  border: 1px solid rgba(90, 77, 57, 0.16);
  color: var(--ink);
}

.summary-unit svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary-stat {
  display: grid;
  grid-template-columns: auto minmax(3ch, 3ch);
  align-items: baseline;
  gap: 8px;
  margin-right: 32px;
}

.summary-stat-label,
.summary-total-label {
  color: rgba(43, 37, 28, 0.86);
}

.summary-stat-value,
.summary-total-value {
  min-width: 4ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.restart-button {
  border: 3px solid var(--line);
  border-radius: 18px;
  padding: 12px 18px;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  color: var(--ink);
  background: linear-gradient(180deg, #fff7e3, #f3d987);
  box-shadow: 0 8px 14px rgba(43, 37, 28, 0.16);
}

@media (max-width: 1100px) {
  .game-shell {
    grid-template-columns: 1fr;
    position: relative;
    overflow: hidden;
  }

  .side-panel {
    position: absolute;
    top: 14px;
    right: 14px;
    bottom: 14px;
    width: min(340px, calc(100% - 28px));
    height: auto;
    max-width: calc(100% - 28px);
    overflow: auto;
    z-index: 24;
    transform: translateX(calc(100% + 18px));
    opacity: 0;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
  }

  .unit-guide {
    grid-template-columns: 1fr;
    height: auto;
  }

  .side-panel-close,
  .unit-guide-toggle,
  .side-panel-backdrop {
    display: block;
  }

  .unit-guide-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    z-index: 18;
    transform: translateY(-50%);
  }

  body.unit-guide-open .side-panel {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  body.unit-guide-open .side-panel-backdrop {
    opacity: 1;
    pointer-events: auto;
    z-index: 20;
  }

  body.unit-guide-open .unit-guide-toggle {
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .title-bar {
    flex-direction: column;
    align-items: start;
  }

  .subtitle {
    text-align: left;
  }

  #overlayTitle {
    font-size: clamp(1.8rem, 7vw, 2.6rem);
  }

  .hud-row {
    grid-template-columns: 1fr;
  }

  .deployment-group {
    right: 24px;
    padding: 7px 8px;
  }

  .deployment-group[data-lane="top"] {
    top: 19%;
  }

  .deployment-group[data-lane="bottom"] {
    top: 80%;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-line-unit {
    grid-template-columns: 38px minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .summary-stat {
    grid-template-columns: auto minmax(2ch, 3ch);
    gap: 6px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 12px, 1380px);
    padding-top: 6px;
  }

  .title-bar,
  .game-shell,
  .overlay-card {
    padding-left: 14px;
    padding-right: 14px;
  }

  .unit-guide {
    grid-template-columns: 1fr;
  }

  .side-panel {
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: calc(100% - 24px);
    max-width: calc(100% - 24px);
    padding: 12px;
  }

  .unit-guide-toggle {
    right: 6px;
    padding: 2px 2px;
    font-size: 0.84rem;
  }

  .deployment-group {
    right: 22px;
    gap: 6px;
    padding: 6px 7px;
  }

  .deploy-buttons {
    gap: 6px;
  }

  .deploy-button {
    width: 46px;
    min-width: 46px;
    height: 50px;
    padding: 4px 3px 6px;
  }

  .deploy-badge {
    width: 24px;
    height: 24px;
    margin-bottom: 3px;
  }

  .deployment-title {
    min-width: 40px;
    font-size: 0.72rem;
  }

  .deploy-note {
    font-size: 0.68rem;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body {
    overflow: hidden;
  }

  .app-shell {
    width: 100%;
    min-height: 100dvh;
    height: 100dvh;
    padding:
      calc(var(--safe-top) + 4px)
      calc(var(--safe-right) + 6px)
      calc(var(--safe-bottom) + 4px)
      calc(var(--safe-left) + 6px);
    gap: 6px;
  }

  .title-bar {
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
    gap: 12px;
  }

  .eyebrow,
  .subtitle {
    display: none;
  }

  h1 {
    font-size: 1.3rem;
  }

  .game-shell {
    padding: 8px;
    gap: 8px;
    overflow: hidden;
  }

  .map-column {
    gap: 8px;
  }

  .hud-row {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.2fr) minmax(0, 0.95fr);
    gap: 4px;
  }

  .hud-card {
    min-height: 0;
    padding: 6px 8px;
    border-radius: 16px;
  }

  .hud-card::after {
    inset: 3px;
    border-radius: 10px;
  }

  .hud-card h3 {
    margin-bottom: 2px;
    font-size: 0.78rem;
    line-height: 1.02;
  }

  .hud-lines {
    gap: 1px;
    font-size: 0.64rem;
    line-height: 1.05;
  }

  .hud-card-center .hud-lines {
    font-size: 0.61rem;
  }

  .hud-card-center .hud-lines strong {
    font-size: 0.68rem;
  }

  .battle-stage {
    height: 100%;
    --mobile-landscape-battlefield-offset: clamp(180px, 24vw, 240px);
    --mobile-landscape-battlefield-left-ratio: 0.203125;
  }

  .canvas-frame {
    padding-right: var(--mobile-landscape-battlefield-offset);
    border-radius: 20px;
  }

  .time-display {
    left: calc(50% - (var(--mobile-landscape-battlefield-offset) / 2));
    top: 8px;
    min-width: 92px;
    padding: 6px 10px;
    border-width: 2px;
    border-radius: 14px;
    font-size: 0.94rem;
    z-index: 4;
  }

  .message-banner {
    top: auto;
    left: calc((100% - var(--mobile-landscape-battlefield-offset)) * var(--mobile-landscape-battlefield-left-ratio));
    right: calc(var(--mobile-landscape-battlefield-offset) + ((100% - var(--mobile-landscape-battlefield-offset)) * var(--mobile-landscape-battlefield-left-ratio)));
    bottom: 10px;
    width: auto;
    max-width: none;
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    line-height: 1.2;
    opacity: 0;
    transform: translateY(6px);
  }

  .message-banner.is-visible {
    opacity: 1;
    transform: translateY(0);
  }

  .deployment-group {
    right: 12px;
    gap: 6px;
    padding: 6px 7px;
    border-radius: 16px;
  }

  .deployment-group::after {
    inset: 4px;
    border-radius: 10px;
  }

  .deployment-group[data-lane="top"] {
    top: 21%;
  }

  .deployment-group[data-lane="bottom"] {
    top: 78%;
  }

  .deployment-title {
    min-width: 36px;
    font-size: 0.66rem;
  }

  .deploy-buttons {
    gap: 4px;
  }

  .deploy-button {
    width: 42px;
    min-width: 42px;
    height: 44px;
    padding: 4px 3px;
    border-radius: 11px;
  }

  .deploy-badge {
    width: 20px;
    height: 20px;
    margin-bottom: 2px;
  }

  .deploy-note {
    font-size: 0.6rem;
  }

  .side-panel {
    position: fixed;
    top: calc(var(--safe-top) + 6px);
    right: calc(var(--safe-right) + 6px);
    bottom: calc(var(--safe-bottom) + 6px);
    width: min(300px, calc(100vw - var(--safe-left) - var(--safe-right) - 16px));
    max-width: none;
    height: auto;
    padding: 10px;
    border-radius: 18px;
  }

  .side-panel::after {
    inset: 4px;
    border-radius: 12px;
  }

  .side-panel-header {
    position: sticky;
    top: 0;
    background: var(--panel-strong);
    z-index: 1;
  }

  .unit-guide {
    margin-top: 6px;
    gap: 6px;
  }

  .unit-guide-card {
    padding: 7px 9px 8px;
    gap: 2px;
  }

  .unit-name,
  .unit-meta,
  .unit-stats,
  .unit-role,
  .unit-matchup {
    font-size: 0.78rem;
  }

  .unit-guide-toggle {
    top: calc(var(--safe-top) + 8px);
    right: calc(var(--safe-right) + 8px);
    transform: none;
    writing-mode: horizontal-tb;
    text-orientation: initial;
    letter-spacing: 0.02em;
    padding: 7px 9px;
    font-size: 0.8rem;
    border-radius: 12px;
    z-index: 19;
  }

  .side-panel-backdrop {
    position: fixed;
  }

  .overlay {
    place-items: start center;
    overflow: auto;
    padding:
      calc(var(--safe-top) + 8px)
      calc(var(--safe-right) + 10px)
      calc(var(--safe-bottom) + 8px)
      calc(var(--safe-left) + 10px);
  }

  .overlay-card {
    width: min(480px, calc(100vw - 20px));
    margin: 0 auto;
    max-height: none;
    overflow: visible;
    padding: 16px 14px;
  }

  #overlayTitle {
    gap: 10px;
    font-size: clamp(1.4rem, 4vw, 2rem);
  }

  .result-badge {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 14px;
  }

  .result-badge svg {
    width: 24px;
    height: 24px;
  }

  .overlay-subtitle {
    margin-top: 8px;
    font-size: 0.9rem;
  }

  .summary-grid {
    gap: 10px;
    margin: 14px 0 16px;
  }

  .summary-card {
    padding: 12px;
  }

  .summary-card h3 {
    margin-bottom: 8px;
    font-size: 1rem;
  }

  .summary-line {
    padding: 5px 0;
    font-size: 0.84rem;
  }

  .summary-unit {
    width: 30px;
    height: 30px;
  }

  .summary-stat {
    margin-right: 32px;
  }

  .restart-button {
    width: 100%;
    padding: 12px 16px;
  }
}
