* {
  box-sizing: border-box;
}

:root {
  --ui-scale: 1;

  --panel-bg: rgba(255, 247, 230, 0.88);
  --panel-border: rgba(90, 55, 20, 0.22);
  --text-main: #1e120a;
  --text-soft: #6f563c;

  --panel-radius: calc(16px * var(--ui-scale));
  --panel-pad: calc(12px * var(--ui-scale));

  --left-panel-w: calc(360px * var(--ui-scale));
  --right-panel-w: calc(300px * var(--ui-scale));
  --chat-w: calc(360px * var(--ui-scale));

  --title-size: calc(28px * var(--ui-scale));
  --text-size: calc(13px * var(--ui-scale));
  --small-size: calc(12px * var(--ui-scale));
  --stat-value-size: calc(16px * var(--ui-scale));

  --hint-size: calc(13px * var(--ui-scale));
  --btn-size: calc(13px * var(--ui-scale));
  --modal-title-size: calc(22px * var(--ui-scale));
  --modal-label-size: calc(13px * var(--ui-scale));
  --chat-size: calc(13px * var(--ui-scale));

  --space-1: calc(6px * var(--ui-scale));
  --space-2: calc(8px * var(--ui-scale));
  --space-3: calc(10px * var(--ui-scale));
  --space-4: calc(12px * var(--ui-scale));
  --space-5: calc(14px * var(--ui-scale));

  --edge-offset: calc(12px * var(--ui-scale));

  --panel-max-h: calc(340px * var(--ui-scale));
  --chat-h: calc(250px * var(--ui-scale));
  --toast-bottom: calc(66px * var(--ui-scale));
  --hint-bottom: calc(22px * var(--ui-scale));
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background: #79c8ff;
  color: var(--text-main);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.panel {
  position: fixed;
  pointer-events: auto;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: var(--panel-radius);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(5px);
}

.top-left {
  left: var(--edge-offset);
  top: var(--edge-offset);
  width: min(var(--left-panel-w), calc(100vw - (var(--edge-offset) * 2)));
  padding: var(--panel-pad);
  max-height: min(var(--panel-max-h), calc(100vh - (var(--edge-offset) * 2)));
  overflow: auto;
}

.top-right {
  right: var(--edge-offset);
  top: var(--edge-offset);
  width: min(var(--right-panel-w), calc(100vw - (var(--edge-offset) * 2)));
  padding: var(--panel-pad);
  max-height: min(var(--panel-max-h), calc(100vh - (var(--edge-offset) * 2)));
  overflow: auto;
}

.title-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  justify-content: space-between;
}

.title-row h1 {
  margin: 0 0 calc(3px * var(--ui-scale)) 0;
  font-size: var(--title-size);
  line-height: 1.05;
}

.title-row p {
  margin: 0;
  font-size: var(--text-size);
  color: var(--text-soft);
  line-height: 1.35;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.stat {
  background: rgba(255, 255, 255, 0.58);
  border-radius: calc(12px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  min-width: 0;
}

.stat.full {
  grid-column: 1 / -1;
}

.stat span {
  display: block;
  font-size: var(--small-size);
  color: #775b3b;
  margin-bottom: calc(3px * var(--ui-scale));
}

.stat strong {
  display: block;
  font-size: var(--stat-value-size);
  word-break: break-word;
  line-height: 1.2;
}

.gold {
  color: #b88700;
}

.action-box {
  margin-top: var(--space-4);
  padding: calc(11px * var(--ui-scale));
  background: rgba(255, 255, 255, 0.52);
  border-radius: calc(12px * var(--ui-scale));
  font-size: var(--small-size);
  line-height: 1.45;
}
.phase-wrap {
  margin-top: 10px;
}

.phase-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--small-size);
  margin-bottom: 6px;
  color: #5f472f;
}

.phase-line strong {
  color: #2b1a0d;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: rgba(60, 33, 10, 0.14);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd76a, #f0a020);
  transition: width 0.25s ease;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.12);
}

.phase-subtext {
  margin-top: 6px;
  font-size: var(--small-size);
  color: #6f563c;
  line-height: 1.35;
}
.phase-banner {
  position: fixed;
  top: calc(14px * var(--ui-scale));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(760px * var(--ui-scale)), 58vw);
  pointer-events: none;
  z-index: 20;
}

.phase-banner-inner {
  background: rgba(255, 247, 230, 0.94);
  border: 3px solid rgba(107, 68, 28, 0.22);
  border-radius: calc(28px * var(--ui-scale));
  box-shadow:
    0 10px 26px rgba(0,0,0,0.12),
    inset 0 -3px 0 rgba(0,0,0,0.06);
  padding: calc(12px * var(--ui-scale)) calc(16px * var(--ui-scale));
  backdrop-filter: blur(4px);
}

.phase-banner-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(12px * var(--ui-scale));
  margin-bottom: calc(8px * var(--ui-scale));
}

.phase-banner-label {
  font-size: calc(18px * var(--ui-scale));
  font-weight: 800;
  color: #40260f;
  text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}

.phase-banner-percent {
  font-size: calc(18px * var(--ui-scale));
  font-weight: 900;
  color: #8a4d00;
}

.phase-banner-track {
  position: relative;
  width: 100%;
  height: calc(28px * var(--ui-scale));
  background: linear-gradient(180deg, #d8cdbd, #c6b8a5);
  border-radius: 999px;
  overflow: hidden;
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.10),
    inset 0 -2px 2px rgba(255,255,255,0.35);
}

.phase-banner-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe16f 0%, #ffbe3b 48%, #ea9208 100%);
  box-shadow:
    inset 0 -2px 0 rgba(0,0,0,0.10),
    inset 0 2px 0 rgba(255,255,255,0.35),
    0 0 14px rgba(255, 190, 59, 0.35);
  transition: width 0.35s ease;
}

.phase-banner-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.20), rgba(255,255,255,0));
  pointer-events: none;
}

.phase-banner-text {
  margin-top: calc(7px * var(--ui-scale));
  text-align: center;
  font-size: calc(14px * var(--ui-scale));
  font-weight: 700;
  color: #6c4a27;
}

@media (max-width: 1100px) {
  .phase-banner {
    width: min(calc(680px * var(--ui-scale)), 64vw);
  }
}

@media (max-width: 900px) {
  .phase-banner {
    top: calc(10px * var(--ui-scale));
    width: calc(100vw - 24px);
  }

  .phase-banner-label,
  .phase-banner-percent {
    font-size: calc(15px * var(--ui-scale));
  }

  .phase-banner-track {
    height: calc(22px * var(--ui-scale));
  }

  .phase-banner-text {
    font-size: calc(12px * var(--ui-scale));
  }
}
h3 {
  margin: 0 0 var(--space-2) 0;
  font-size: calc(14px * var(--ui-scale));
}

.board {
  margin-bottom: var(--space-5);
}
.outfit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.outfit-card {
  background: rgba(255,255,255,0.72);
  border: 2px solid rgba(90, 55, 20, 0.15);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.outfit-card.locked {
  opacity: 0.62;
  filter: grayscale(0.25);
}

.outfit-card.active {
  border-color: rgba(216, 164, 0, 0.9);
  box-shadow: 0 0 0 2px rgba(255, 220, 120, 0.55);
}

.outfit-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: rgba(255,255,255,0.72);
  border-radius: 12px;
  padding: 8px;
}

.outfit-title {
  font-weight: 800;
  font-size: 14px;
  color: #2f1c0c;
}

.outfit-sub {
  font-size: 12px;
  color: #6f563c;
  line-height: 1.35;
  min-height: 32px;
}

.outfit-card button {
  margin-top: auto;
}
.leaderItem {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  padding: calc(7px * var(--ui-scale)) 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  font-size: var(--small-size);
}

.rank {
  color: #b67a00;
  font-weight: 700;
  margin-right: calc(6px * var(--ui-scale));
}

.interaction-hint {
  position: fixed;
  left: 50%;
  bottom: var(--hint-bottom);
  transform: translateX(-50%);
  display: none;
  pointer-events: none;
  background: rgba(33, 22, 13, 0.88);
  color: #fff7e7;
  padding: calc(10px * var(--ui-scale)) calc(16px * var(--ui-scale));
  border-radius: 999px;
  font-size: var(--hint-size);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  max-width: calc(100vw - 40px);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--toast-bottom);
  transform: translateX(-50%);
  background: rgba(33, 22, 13, 0.94);
  color: #fff7e7;
  padding: calc(10px * var(--ui-scale)) calc(16px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  font-size: var(--hint-size);
  max-width: calc(100vw - 40px);
  text-align: center;
}

.btn {
  border: none;
  cursor: pointer;
  border-radius: calc(11px * var(--ui-scale));
  padding: calc(9px * var(--ui-scale)) calc(13px * var(--ui-scale));
  font-weight: 700;
  font-size: var(--btn-size);
  background: linear-gradient(180deg, #ffcf6f, #d48a24);
  color: #2f1c0c;
  flex-shrink: 0;
}

.secondary-btn {
  background: linear-gradient(180deg, #e6ddd0, #bfb3a2);
}

.gold-btn {
  background: linear-gradient(180deg, #fff0a8, #d8a400);
}

.modal-wrap {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  padding: 16px;
}

.modal {
  width: min(calc(420px * var(--ui-scale)), 92vw);
  max-height: min(calc(520px * var(--ui-scale)), 90vh);
  overflow: auto;
  background: #fff6e8;
  color: #23160d;
  border-radius: calc(18px * var(--ui-scale));
  padding: calc(16px * var(--ui-scale));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.modal h2 {
  margin-top: 0;
  font-size: var(--modal-title-size);
}

.modal label {
  display: block;
  margin-top: calc(10px * var(--ui-scale));
  margin-bottom: calc(5px * var(--ui-scale));
  font-size: var(--modal-label-size);
  font-weight: 700;
}

.modal input {
  width: 100%;
  padding: calc(10px * var(--ui-scale)) calc(11px * var(--ui-scale));
  border-radius: calc(11px * var(--ui-scale));
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  font-size: var(--text-size);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.chat-wrap {
  left: var(--edge-offset);
  bottom: var(--edge-offset);
  width: min(var(--chat-w), calc(100vw - (var(--edge-offset) * 2)));
  height: min(var(--chat-h), calc(100vh - (var(--edge-offset) * 2)));
  padding: calc(10px * var(--ui-scale));
}

.chat-wrap.hidden {
  display: none;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: calc(12px * var(--ui-scale));
  margin-bottom: var(--space-2);
  color: #6a5138;
}

.chat-messages {
  height: calc(100% - calc(48px * var(--ui-scale)));
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.52);
  border-radius: calc(12px * var(--ui-scale));
  padding: calc(9px * var(--ui-scale));
  font-size: var(--chat-size);
}

.chat-line {
  margin-bottom: calc(7px * var(--ui-scale));
  line-height: 1.35;
}

.chat-name {
  font-weight: 700;
  color: #7a4e23;
}

#chatInput {
  width: 100%;
  margin-top: var(--space-2);
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #fff;
  outline: none;
  font-size: var(--chat-size);
}

/* Groß, aber nicht unnötig fett */
@media (min-width: 1700px) and (min-height: 900px) {
  :root {
    --ui-scale: 0.95;
  }
}

/* Standard-Laptops / mittlere Displays */
@media (max-width: 1600px), (max-height: 900px) {
  :root {
    --ui-scale: 0.9;
  }
}

/* Kleine Laptops / niedrigere Höhe */
@media (max-width: 1366px), (max-height: 820px) {
  :root {
    --ui-scale: 0.82;
  }
}

/* Sehr niedrige Displays / TV-Browser / kleine Fenster */
@media (max-width: 1200px), (max-height: 720px) {
  :root {
    --ui-scale: 0.74;
  }
}

/* Sehr kleine Geräte */
@media (max-width: 900px) {
  :root {
    --ui-scale: 0.78;
  }

  .top-left,
  .top-right {
    width: calc(100vw - 24px);
    position: fixed;
    left: 12px;
    right: 12px;
  }

  .top-left {
    top: 12px;
    max-height: 44vh;
  }

  .top-right {
    top: auto;
    bottom: 12px;
    max-height: 28vh;
  }

  .chat-wrap {
    width: calc(100vw - 24px);
    left: 12px;
    bottom: 12px;
    height: min(calc(220px * var(--ui-scale)), 30vh);
  }
}

/* Extrem kleine Höhe */
@media (max-height: 620px) {
  :root {
    --ui-scale: 0.68;
  }

  .top-left,
  .top-right {
    max-height: 30vh;
  }

  .chat-wrap {
    height: min(calc(180px * var(--ui-scale)), 26vh);
  }
  #outfitBtn {
  pointer-events: auto;
  position: relative;
  z-index: 50;
}
.action-box {
  pointer-events: auto;
}
}
