/* =========================================================================
   Wrath of Darkness - UI styling (dark fantasy theme)
   The game world itself is drawn on the canvas; this file styles the HTML overlays.
   ========================================================================= */

:root {
  --bg: #07060a;
  --panel: #16111b;
  --panel-2: #1e1724;
  --panel-border: #3d2c42;
  --text: #ece4d4;
  --text-dim: #a99fae;
  --gold: #e9c46a;
  --gold-bright: #ffd23f;
  --blood: #b3122e;
  --blood-bright: #e0304e;
  --mana: #3d7bd9;
  --exp: #8a6cff;
  --hp: #d63a3a;
  --p1: #ffd23f;
  --p2: #4fd8ff;
  --focus: #ffd23f;
  --radius: 12px;
  --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);
  --title-font: "Cinzel", "Trajan Pro", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --ui-font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui-font);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.hidden { display: none !important; }

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 18px;
}

#game-root {
  position: fixed;
  inset: 0;
}

#game-canvas {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

/* ------------------------------------------------------------- overlays & panels */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(14px + var(--safe-top)) calc(14px + var(--safe-right)) calc(14px + var(--safe-bottom)) calc(14px + var(--safe-left));
  background: radial-gradient(ellipse at center, rgba(25, 10, 20, 0.6), rgba(4, 3, 6, 0.88));
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

/* Painted key art (ImagineArt) behind the menus */
#main-menu,
#preloader {
  background:
    radial-gradient(ellipse at 50% 35%, rgba(20, 5, 12, 0.25), rgba(4, 3, 6, 0.8) 75%),
    url('assets/ui/keyart.webp') center 30% / cover no-repeat,
    #07060a;
}

#main-menu .menu-panel,
#preloader .menu-panel {
  background: linear-gradient(180deg, rgba(26, 18, 32, 0.84), rgba(14, 10, 18, 0.9));
  backdrop-filter: blur(3px);
}

.menu-panel {
  margin: auto;
  width: min(940px, 100%);
  padding: 18px 18px 16px;
  background: linear-gradient(180deg, rgba(30, 22, 36, 0.97), rgba(18, 13, 22, 0.97));
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.small-panel {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}

.small-panel h2 { margin: 4px 0 6px; }
.small-panel p { margin: 0 0 6px; color: var(--text-dim); }

.loader-panel { padding: 26px 22px; }

.game-title {
  margin: 0;
  text-align: center;
  font-family: var(--title-font);
  font-weight: 700;
  font-size: clamp(28px, 6.2vw, 50px);
  letter-spacing: 0.06em;
  color: #eadbb8;
  text-shadow: 0 0 18px rgba(224, 48, 78, 0.55), 0 2px 0 #3a0a14;
  line-height: 1.05;
}

.game-title span {
  font-size: 0.55em;
  font-style: italic;
  color: var(--blood-bright);
  vertical-align: middle;
}

.tagline {
  margin: 6px 0 14px;
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
}

h2, h3 {
  font-family: var(--title-font);
  letter-spacing: 0.04em;
  color: #eadbb8;
}

h2 { font-size: 20px; margin: 0; }
h3 { font-size: 16px; margin: 0; }

.danger-text { color: var(--blood-bright); }

/* ------------------------------------------------------------- loader */

.loader-track {
  height: 12px;
  margin: 20px 0 10px;
  background: #0d0a10;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  overflow: hidden;
}

.loader-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--blood), var(--gold));
  transition: width 0.2s ease;
}

.loader-text { margin: 0; text-align: center; color: var(--text-dim); }

/* ------------------------------------------------------------- buttons */

.btn {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid #5b4462;
  border-radius: 10px;
  background: linear-gradient(180deg, #2f2436, #221a28);
  color: var(--text);
  font: 700 15px var(--ui-font);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}

.btn:hover:not(:disabled) { border-color: #8a6a92; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.42; cursor: default; }

.btn-primary {
  background: linear-gradient(180deg, #9c1c34, #6d0f22);
  border-color: #d0405e;
}

.btn-primary:hover:not(:disabled) { border-color: #ff6f8a; }

.btn-danger {
  background: linear-gradient(180deg, #2a1515, #1b0d0d);
  border-color: #6e2a2a;
  color: #ff9b9b;
}

.btn-large { min-width: 200px; font-size: 17px; }

/* Link styled as a button: back to the game hub */
a.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-games {
  background: linear-gradient(180deg, #1c2333, #121826);
  border-color: #4a5d85;
  color: #cfe0ff;
  letter-spacing: 0.08em;
}

.btn.armed {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  animation: pulse 0.9s ease-in-out infinite;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.btn-row .btn { flex: 1 1 auto; }

:focus { outline: none; }
:focus-visible,
.gp-focus {
  outline: 3px solid var(--focus) !important;
  outline-offset: 2px;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 210, 63, 0.0); }
  50% { box-shadow: 0 0 14px 2px rgba(255, 210, 63, 0.45); }
}

/* ------------------------------------------------------------- main menu */

.save-info {
  margin: 0 auto 12px;
  max-width: 560px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}

.save-summary {
  margin: 0 0 8px;
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
}

.menu-group {
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  min-width: 0;
}

.menu-group legend {
  margin-bottom: 6px;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented label {
  position: relative;
  flex: 1 1 0;
  min-width: 90px;
}

/* Radios stay focusable but invisible; the span is the visible button */
.segmented input,
.class-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #4a3a50;
  border-radius: 10px;
  background: #1d1622;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
}

.segmented input:checked + span {
  background: linear-gradient(180deg, #4a1a2c, #2d1019);
  border-color: var(--blood-bright);
  color: var(--text);
}

.segmented label.gp-focus,
.class-option.gp-focus { border-radius: 10px; }

/* Keyboard focus on the hidden radios shows on their visible part */
.segmented input:focus-visible + span,
.class-option:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.player-setup {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 720px) {
  .player-setup { grid-template-columns: 1fr 1fr; }
}

.player-card {
  padding: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}

.player-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 18px;
}

.player-tag {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  font: 800 12px var(--ui-font);
  letter-spacing: 0.04em;
}

.player-tag.p1 { color: var(--p1); border: 1px solid rgba(255, 210, 63, 0.5); }
.player-tag.p2 { color: var(--p2); border: 1px solid rgba(79, 216, 255, 0.5); }

.class-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.class-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 8px;
  border: 1px solid #4a3a50;
  border-radius: 10px;
  background: #1d1622;
  text-align: center;
  cursor: pointer;
}

.class-option:has(input:checked) {
  border-color: var(--gold);
  background: linear-gradient(180deg, #3a2a1a, #21170f);
  box-shadow: 0 0 12px rgba(233, 196, 106, 0.25);
}

.class-option strong { font-size: 14px; }
.class-option small { font-size: 11px; color: var(--text-dim); }

.class-swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 2px solid rgba(0, 0, 0, 0.5);
}

/* Class portraits: the painted hero sprites (ImagineArt) */
.class-swatch[data-class] {
  width: 58px;
  height: 64px;
  border: 0;
  border-radius: 0;
  background: center bottom / contain no-repeat;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.6));
}
.class-swatch[data-class="warrior"] { background-image: url('assets/sprites/warrior.webp'); }
.class-swatch[data-class="mage"] { background-image: url('assets/sprites/mage.webp'); }
.class-swatch[data-class="archer"] { background-image: url('assets/sprites/archer.webp'); }

.device-status {
  min-height: 1.3em;
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.setup-error {
  min-height: 1.3em;
  margin: 8px 0;
  text-align: center;
  color: #ff8a8a;
  font-weight: 700;
}

.controls-help {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 13px;
}

.controls-help summary {
  cursor: pointer;
  text-align: center;
  font-weight: 700;
  color: var(--gold);
  padding: 8px;
}

.table-scroll { overflow-x: auto; }

.controls-help table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

.controls-help th,
.controls-help td {
  padding: 5px 6px;
  border-bottom: 1px solid #2c2131;
  text-align: left;
  white-space: nowrap;
}

.controls-help th { color: var(--text); }
.help-note { margin: 8px 0 0; text-align: center; }

/* ------------------------------------------------------------- HUD */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: calc(6px + var(--safe-top)) calc(8px + var(--safe-right)) 0 calc(8px + var(--safe-left));
  pointer-events: none;
}

.hud-players {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hud-player {
  width: 178px;
  padding: 5px 7px 6px;
  background: rgba(10, 7, 13, 0.72);
  border: 1px solid rgba(80, 60, 90, 0.7);
  border-radius: 10px;
  /* no backdrop-filter here: blurring the moving game view every frame is expensive on phones */
}

.hud-player.downed { filter: grayscale(1); opacity: 0.6; }

.hud-head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.hud-class { color: var(--text); }
.hud-level { color: var(--gold); }
.hud-points { color: var(--gold-bright); animation: pulse 1.2s infinite; border-radius: 4px; padding: 0 3px; }
.hud-potions { margin-left: auto; font-size: 11px; color: var(--text-dim); }

.bar {
  position: relative;
  height: 11px;
  margin-top: 3px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  overflow: hidden;
}

.bar-hp { height: 13px; }
.bar-exp { height: 6px; }

.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 4px;
  transition: width 0.15s linear;
}

.bar-hp .bar-fill { background: linear-gradient(180deg, #ef5350, #a61e1e); }
.bar-mana .bar-fill { background: linear-gradient(180deg, #5b9cf0, #2050a8); }
.bar-exp .bar-fill { background: linear-gradient(180deg, #a48bff, #5d3fd3); }

.bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  line-height: 1;
}

.bar-exp .bar-text { display: none; }

.hud-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-top: 2px;
  text-align: center;
  font-weight: 700;
  text-shadow: 0 1px 3px #000;
  min-width: 0;
}

.hud-biome {
  font-family: var(--title-font);
  font-size: 14px;
  color: #eadbb8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.hud-enemies { font-size: 12px; color: var(--text-dim); }

.hud-actions {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #5b4462;
  border-radius: 12px;
  background: rgba(20, 14, 24, 0.82);
  color: var(--text);
  font: 800 18px var(--ui-font);
  cursor: pointer;
  touch-action: manipulation;
}

.icon-btn:active { transform: scale(0.94); }

.icon-btn.attention {
  color: var(--gold-bright);
  border-color: var(--gold-bright);
  animation: pulse 1.1s ease-in-out infinite;
}

@media (max-width: 700px) {
  .hud-player { width: 136px; padding: 4px 5px 5px; }
  .hud-head { font-size: 11px; gap: 3px; }
  .hud-potions { display: none; }
  .hud-biome { font-size: 12px; }
  .hud-enemies { font-size: 11px; }
  .icon-btn { width: 40px; height: 40px; font-size: 16px; }
}

@media (max-width: 520px) {
  #hud { flex-wrap: wrap; }
  .hud-center { order: 3; flex-basis: 100%; }
}

/* ------------------------------------------------------------- touch controls */

#touch-controls {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.joystick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 50%;
  height: 70%;
  pointer-events: auto;
  touch-action: none;
}

.joystick-base {
  position: absolute;
  left: calc(90px + var(--safe-left));
  top: calc(100% - 100px - var(--safe-bottom));
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 2px solid rgba(255, 255, 255, 0.22);
  opacity: 0.45;
  pointer-events: none;
}

.joystick-base.active { opacity: 1; border-color: rgba(255, 210, 63, 0.6); }

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50px;
  height: 50px;
  margin: -25px 0 0 -25px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.55), rgba(200, 190, 210, 0.25));
  border: 2px solid rgba(255, 255, 255, 0.45);
}

.touch-buttons {
  position: absolute;
  right: calc(14px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  width: 200px;
  height: 190px;
  pointer-events: none;
}

.touch-btn {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font: 800 26px var(--ui-font);
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.touch-btn.active { transform: scale(0.92); filter: brightness(1.4); }

.touch-attack {
  right: 0;
  bottom: 0;
  width: 92px;
  height: 92px;
  background: radial-gradient(circle at 35% 35%, rgba(224, 48, 78, 0.85), rgba(110, 15, 34, 0.75));
  font-size: 34px;
}

.touch-special {
  right: 104px;
  bottom: 6px;
  width: 70px;
  height: 70px;
  background: radial-gradient(circle at 35% 35%, rgba(91, 156, 240, 0.85), rgba(32, 80, 168, 0.75));
}

.touch-potion {
  right: 18px;
  bottom: 106px;
  width: 58px;
  height: 58px;
  background: radial-gradient(circle at 35% 35%, rgba(76, 217, 100, 0.7), rgba(20, 90, 40, 0.7));
  font-size: 22px;
}

/* ------------------------------------------------------------- skill tree & shared panel parts */

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tabs { display: flex; gap: 6px; }

.tab {
  min-height: 38px;
  padding: 6px 14px;
  border: 1px solid #4a3a50;
  border-radius: 999px;
  background: #1d1622;
  color: var(--text-dim);
  font: 700 13px var(--ui-font);
  cursor: pointer;
}

.tab.active {
  color: var(--text);
  border-color: var(--gold);
  background: linear-gradient(180deg, #3a2a1a, #21170f);
}

.skill-panel { width: min(760px, 100%); }

.skill-points { margin: 0 0 10px; color: var(--text-dim); }
.skill-points strong { color: var(--gold-bright); font-size: 18px; }

.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.skill-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 10px;
  text-align: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}

.skill-node.maxed { border-color: var(--gold); }

.skill-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle, #3c2a40, #1a121e);
  border: 2px solid #6d5274;
  font-size: 22px;
  color: var(--gold);
}

.skill-node p { margin: 0; font-size: 13px; }
.skill-desc { color: var(--text-dim); }
.skill-rank { font-weight: 800; color: var(--gold); }
.skill-preview { min-height: 1.2em; color: #9fe3a5; }
.skill-buy { width: 100%; margin-top: 4px; }

.stat-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 12px 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  font-size: 13px;
}

.stat-summary dt { color: var(--text-dim); }
.stat-summary dd { margin: 0; font-weight: 700; text-align: right; }
.stat-summary.compact { margin: 8px 0 0; font-size: 12px; padding: 8px 10px; }

/* ------------------------------------------------------------- inventory */

.inventory-panel { width: min(980px, 100%); }

.inventory-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 620px) {
  .inventory-layout { grid-template-columns: minmax(150px, 190px) minmax(230px, 1.2fr) minmax(200px, 1fr); }
}

.equip-column { display: flex; flex-direction: column; gap: 8px; }

.equip-slot {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  padding: 8px;
  min-height: 62px;
  text-align: left;
  border: 2px solid var(--rarity, #4a3a50);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: 600 13px var(--ui-font);
  cursor: pointer;
}

.equip-slot.empty { border-color: #4a3a50; border-style: dashed; }
.equip-slot.selected { box-shadow: 0 0 0 2px var(--gold-bright); }

.slot-label {
  grid-column: 2;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.slot-icon {
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 24px;
}

.slot-name { grid-column: 2; font-weight: 700; line-height: 1.2; }

.bag-head {
  display: flex;
  justify-content: space-between;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.inv-slot {
  position: relative;
  aspect-ratio: 1;
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--rarity, #3a2d40);
  border-radius: 10px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.35));
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
}

.inv-slot.empty {
  border-color: #2e2333;
  background: rgba(0, 0, 0, 0.25);
  cursor: default;
}

.inv-slot.rarity-rare { box-shadow: inset 0 0 10px rgba(77, 163, 255, 0.35); }
.inv-slot.rarity-epic { box-shadow: inset 0 0 12px rgba(184, 107, 255, 0.45); }
.inv-slot.rarity-legendary { box-shadow: inset 0 0 14px rgba(255, 182, 54, 0.55); animation: pulse 1.6s infinite; }
.inv-slot.selected { outline: 3px solid var(--gold-bright); outline-offset: 1px; }
.inv-slot.unusable { opacity: 0.55; }

.item-details {
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  min-height: 180px;
  -webkit-user-select: text;
  user-select: text;
}

.item-details.empty h3 { color: var(--text-dim); }

.item-meta { margin: 4px 0 8px; font-size: 12px; color: var(--text-dim); }

.item-stats,
.item-compare {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
}

.item-stats li { color: #9fe3a5; }
.item-compare li { font-size: 13px; }
.item-compare .compare-head { color: var(--text-dim); font-weight: 600; font-size: 12px; }
.item-compare .better { color: #6be38a; }
.item-compare .worse { color: #ff7b7b; }

.item-desc { margin: 0 0 8px; font-size: 13px; font-style: italic; color: var(--text-dim); }
.item-message { min-height: 1.2em; margin: 0 0 8px; font-size: 13px; color: var(--gold-bright); font-weight: 700; }
.item-actions { justify-content: flex-start; }

/* ------------------------------------------------------------- toast & hints */

.toast {
  position: fixed;
  left: 50%;
  top: calc(78px + var(--safe-top));
  z-index: 25; /* above the HUD, below menus */
  max-width: min(560px, calc(100% - 24px));
  padding: 9px 14px;
  border-left: 4px solid var(--toast-color, var(--gold));
  border-radius: 10px;
  background: rgba(14, 10, 18, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

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

.rotate-hint {
  position: fixed;
  left: 50%;
  bottom: calc(210px + var(--safe-bottom));
  z-index: 40;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(14, 10, 18, 0.88);
  border: 1px solid var(--panel-border);
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 0.3s ease;
  white-space: nowrap;
}

.rotate-hint.show { opacity: 1; }

/* ------------------------------------------------------------- small heights (landscape phones) */

/* The start button stays visible while the menu scrolls */
.start-row {
  position: sticky;
  bottom: -14px;
  z-index: 2;
  margin: 0 -18px -16px;
  padding: 10px 18px 14px;
  background: linear-gradient(180deg, rgba(18, 13, 22, 0), rgba(18, 13, 22, 0.96) 35%);
  border-radius: 0 0 16px 16px;
}

@media (max-height: 460px) {
  .menu-panel { padding: 12px; }
  .start-row { margin: 0 -12px -12px; padding: 8px 12px 10px; bottom: -14px; }
  .game-title { font-size: 28px; }
  .tagline { display: none; }
  .save-info { margin-bottom: 8px; padding: 6px 10px; }
  .toast { font-size: 12px; padding: 6px 10px; }
  .class-option { padding: 6px 4px; }
  .class-swatch[data-class] { width: 40px; height: 44px; }
  .player-card { padding: 8px; }
  .toast { top: calc(64px + var(--safe-top)); }
  .touch-buttons { transform: scale(0.88); transform-origin: bottom right; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------- item icons (assets/ui/items.webp) */

.slot-glyph,
.slot-icon,
.item-icon {
  background-repeat: no-repeat;
  background-size: 500% 400%;
}

.slot-glyph {
  display: grid;
  place-items: center;
  width: 86%;
  height: 86%;
}

.has-icon { background-image: url('assets/ui/items.webp'); }

.item-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.item-icon {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.04);
}

.item-details.empty .item-icon { display: none; }

/* Potion touch button shows the painted health potion (frame 16) */
.touch-potion {
  padding: 8px;
  background:
    url('assets/ui/items.webp') 25% 100% / 500% 400% no-repeat,
    radial-gradient(circle at 35% 35%, rgba(76, 217, 100, 0.55), rgba(20, 90, 40, 0.7));
  background-origin: content-box, border-box;
}
