:root{
  --bg:#05060a;
  --panel:#0c111a;
  --panel2:#070a10;
  --text:#e8f7ff;
  --muted:#9ab2bf;
  --line:#29f2ff;
  --line2:#ff4ee3;
  --danger:#ff3d3d;
  --good:#2dff9b;
  --amber:#ffcc66;
  --shadow: 0 12px 40px rgba(0,0,0,.60);
  --radius: 14px;
  --display: "Oxanium", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --collapsed-panel-width: 50px;
  --collapsed-panel-height: 50px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:
    radial-gradient(1200px 700px at 15% 15%, rgba(41,242,255,.15), transparent 55%),
    radial-gradient(900px 600px at 85% 25%, rgba(255,78,227,.12), transparent 55%),
    radial-gradient(900px 600px at 50% 80%, rgba(45,255,155,.08), transparent 60%),
    linear-gradient(180deg, #030407, #05060a 55%, #030407);
  color:var(--text);
  font-family: var(--display);
  letter-spacing:.2px;
}

.app-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid rgba(41,242,255,.30);
  background:linear-gradient(180deg, rgba(12,17,26,.92), rgba(5,6,10,.72));
  position:sticky;
  top:0;
  z-index:20;
  backdrop-filter: blur(10px);
}

.brand__title{
  font-weight:700;
  font-size:20px;
  text-transform:uppercase;
  letter-spacing:2px;
}
.brand__subtitle{ font-size:12px; color:var(--muted); margin-top:2px; font-family: var(--mono); }

.header-actions{ display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }

.app{
  display:grid;
  gap:14px;
  padding:14px;
  transition: grid-template-columns 0.3s ease-in-out;
  align-items: start;
}

@media (min-width: 1101px) {
  .app { grid-template-columns: 320px 1fr 420px; }
}

@media (max-width: 1100px){
  .app{ grid-template-columns: 280px 1fr; grid-template-rows:auto auto; }
  .action{ grid-column: 1 / -1; }
}

@media (max-width: 760px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{ order:2; }
  .action{ order:3; }
}

.sidebar, .story, .action{
  background:linear-gradient(180deg, rgba(12,17,26,.92), rgba(7,10,16,.86));
  border:1px solid rgba(41,242,255,.22);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction: column;
  transition: width 0.3s ease-in-out, height 0.3s ease-in-out, padding 0.3s ease-in-out;
}

.story{ height: calc(100vh - 140px); }
@media (max-width: 1100px){
  .story{ height: auto; min-height: 260px; max-height: 50vh; }
}

.panel-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 8px 12px;
  border-bottom:1px solid rgba(41,242,255,.18);
  cursor:pointer;
  flex-shrink:0;
}

.panel-title{
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:2px;
  color:rgba(232,247,255,.90);
  font-size:13px;
  margin:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.panel-toggle-btn{
  background:none;
  border:none;
  color:var(--text);
  cursor:pointer;
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform 0.2s ease-in-out;
}

.panel-toggle-btn svg{ width:18px; height:18px; }
.sidebar .panel-toggle-btn.collapsed svg { transform: rotate(-90deg); }
.story .panel-toggle-btn.collapsed svg { transform: rotate(180deg); }
.action .panel-toggle-btn.collapsed svg { transform: rotate(90deg); }

.panel-content{
  flex-grow:1;
  overflow:auto;
  padding:12px;
}

.sidebar.panel--collapsed,
.action.panel--collapsed{
  width: var(--collapsed-panel-width);
  min-width: var(--collapsed-panel-width);
  padding:0;
}
.story.panel--collapsed{
  height: var(--collapsed-panel-height);
  min-height: var(--collapsed-panel-height);
  padding:0;
}
.panel--collapsed .panel-content{ display:none; }
.sidebar.panel--collapsed .panel-title,
.action.panel--collapsed .panel-title{ display:none; }
.panel--collapsed .panel-header{ border-bottom:none; }

.story:not(.panel--collapsed) .story__top{
  padding: 12px 12px 10px;
  border-bottom:1px solid rgba(41,242,255,.18);
  flex-shrink:0;
}
.story:not(.panel--collapsed) .story__log{
  padding:12px;
  overflow:auto;
  flex-grow:1;
}

.players{ display:flex; flex-direction:column; gap:12px; }

.player-card{
  padding:12px;
  border-radius:12px;
  border:1px solid rgba(255,78,227,.22);
  background:linear-gradient(180deg, rgba(0,0,0,.30), rgba(0,0,0,.10));
}

.player-card--dead{ opacity:.62; border-color: rgba(255,61,61,.45); }

.player-card__top{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.player-card__name{ font-weight:700; font-size:16px; }
.player-card__sub{ color:var(--muted); font-size:12px; margin-top:2px; font-family: var(--mono); }

.skulls{
  font-size:12px;
  padding:6px 8px;
  border-radius:10px;
  border:1px solid rgba(41,242,255,.30);
  background: rgba(0,0,0,.25);
  white-space:nowrap;
  font-family: var(--mono);
}

.traits{ display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.trait-btn{
  appearance:none;
  border:1px solid rgba(41,242,255,.30);
  background: rgba(0,0,0,.18);
  color: var(--text);
  border-radius: 999px;
  padding:6px 10px;
  font-family: var(--mono);
  cursor:pointer;
  font-size:12px;
}
.trait-btn[aria-pressed="true"]{
  border-color: rgba(45,255,155,.75);
  box-shadow: 0 0 0 2px rgba(45,255,155,.15) inset;
}
.trait-btn--scarred{ border-color: rgba(255,78,227,.55); }

.story__top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
}

.location-description{
  font-size:13px;
  color:rgba(232,247,255,.92);
  line-height:1.45;
  margin-top: 8px;
  margin-bottom: 10px;
  padding: 8px 0;
  border-top: 1px dashed rgba(41,242,255,.14);
  border-bottom: 1px dashed rgba(41,242,255,.14);
  font-family: var(--mono);
}

.status-line{ font-size:12px; color:var(--muted); margin-top:6px; font-family: var(--mono); }

.signal{
  min-width: 220px;
  border:1px solid rgba(255,78,227,.18);
  border-radius:12px;
  padding:10px 12px;
  background: rgba(0,0,0,.15);
}
.signal__label{ font-size:11px; text-transform:uppercase; letter-spacing:2px; color:rgba(255,78,227,.92); }
.signal__label--sub{ margin-top:10px; color:rgba(41,242,255,.92); }
.signal__text{ margin-top:6px; font-size:13px; color:rgba(232,247,255,.92); font-family: var(--mono); }

.log-entry{
  border-left: 2px solid rgba(41,242,255,.45);
  padding:10px 12px;
  margin:0 0 10px;
  background: rgba(0,0,0,.12);
  border-radius: 10px;
}
.log-entry__meta{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
  font-size:12px;
  color:var(--muted);
  font-family: var(--mono);
}
.log-entry__title{ font-weight:700; font-size:13px; color: rgba(232,247,255,.95); font-family: var(--display); }
.log-entry__text{ margin-top:6px; line-height:1.45; color: rgba(232,247,255,.92); white-space: pre-line; font-family: var(--mono); }

.card{
  padding:12px;
  border-radius: 12px;
  border:1px solid rgba(41,242,255,.22);
  background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,.06));
  box-shadow: 0 10px 28px rgba(0,0,0,.25);
}
.card--thin{ margin-top:12px; }

.card__title{ margin:0 0 6px; font-size:16px; }
.card__hint{ margin:0 0 12px; color: var(--muted); font-size:12px; font-family: var(--mono); }

.hidden{ display:none !important; }

.field{ display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--muted); font-family: var(--mono); }
.field > span{ letter-spacing:1px; }
.field--full{ width:100%; }

.input{
  width:100%;
  border:1px solid rgba(41,242,255,.30);
  border-radius: 12px;
  padding:10px 12px;
  background: rgba(0,0,0,.18);
  color: var(--text);
  font-family: var(--mono);
  outline:none;
}
.input:focus{ border-color: rgba(45,255,155,.85); box-shadow: 0 0 0 3px rgba(45,255,155,.12); }
.input--textarea{ resize:vertical; min-height: 90px; }

.setup{ display:flex; flex-direction:column; gap:12px; }
.setup__row{ display:flex; gap:10px; align-items:flex-end; }
.setup__row--end{ justify-content:flex-end; }
.setup__players{ display:flex; flex-direction:column; gap:10px; }

.player-form{
  display:grid;
  grid-template-columns: 1.2fr 1fr;
  gap:10px;
  padding:10px;
  border:1px dashed rgba(255,78,227,.28);
  border-radius: 12px;
  background: rgba(0,0,0,.12);
}
.player-form__traits{ grid-column: 1 / -1; display:grid; grid-template-columns: 1fr 1fr; gap:10px; }

.btn{
  border:1px solid rgba(41,242,255,.45);
  background: rgba(0,0,0,.20);
  color: var(--text);
  border-radius: 12px;
  padding:10px 12px;
  cursor:pointer;
  font-family: var(--display);
  text-transform:uppercase;
  letter-spacing:1.5px;
  font-weight:700;
  font-size:12px;
}
.btn:hover{ border-color: rgba(45,255,155,.85); }
.btn:disabled{ opacity:.55; cursor:not-allowed; }

.btn--primary{ border-color: rgba(45,255,155,.70); background: linear-gradient(180deg, rgba(45,255,155,.16), rgba(0,0,0,.18)); }
.btn--danger{ border-color: rgba(255,61,61,.70); }
.btn--ghost{ border-color: rgba(255,78,227,.55); }

.turn{ display:flex; flex-direction:column; gap:12px; }
.turn__row{ display:flex; gap:10px; align-items:flex-start; }
.turn__row--end{ justify-content:space-between; align-items:center; }

.cr-box{
  border:1px solid rgba(255,78,227,.22);
  border-radius: 12px;
  padding:10px 12px;
  background: rgba(0,0,0,.14);
  min-width: 170px;
  text-align:right;
  font-family: var(--mono);
}
.cr-box__phase{ font-size:11px; text-transform:uppercase; letter-spacing:2px; color:rgba(255,78,227,.92); font-family: var(--display); }
.cr-box__cr{ margin-top:6px; font-size:14px; font-weight:700; }

.trait-picker{ display:flex; flex-wrap:wrap; gap:8px; margin-top:2px; }

.dice{ display:flex; flex-direction:column; gap:8px; }
.dice__label{ font-size:12px; color: var(--muted); text-transform:uppercase; letter-spacing:2px; font-family: var(--mono); }

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

.die{
  width:56px;
  height:56px;
  border-radius: 14px;
  border:1px solid rgba(41,242,255,.50);
  background: rgba(0,0,0,.18);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:34px;
  line-height:1;
  color: rgba(232,247,255,.96);
  box-shadow:
    0 0 0 2px rgba(41,242,255,.08) inset,
    0 12px 26px rgba(0,0,0,.35);
  text-shadow: 0 0 10px rgba(41,242,255,.20);
}

.die--rolling{
  animation: die-shake 0.12s infinite linear;
  border-color: rgba(45,255,155,.75);
  box-shadow:
    0 0 0 2px rgba(45,255,155,.12) inset,
    0 0 18px rgba(45,255,155,.16),
    0 12px 26px rgba(0,0,0,.35);
}

@keyframes die-shake{
  0%{ transform: translate(0,0) rotate(0deg); }
  25%{ transform: translate(1px,-1px) rotate(-2deg); }
  50%{ transform: translate(-1px,1px) rotate(2deg); }
  75%{ transform: translate(1px,1px) rotate(-1deg); }
  100%{ transform: translate(0,0) rotate(0deg); }
}

.dice__readout{
  font-size:12px;
  font-weight:700;
  padding:10px 12px;
  border-radius: 12px;
  border:1px solid rgba(41,242,255,.28);
  background: rgba(0,0,0,.16);
  min-width: 160px;
  font-family: var(--mono);
}

.consequence{ font-size:12px; color:var(--muted); line-height:1.35; font-family: var(--mono); }
.mini-hint{ font-size:11px; color: rgba(154,178,191,.95); line-height:1.35; font-family: var(--mono); }

.dialog{
  width:min(660px, calc(100vw - 24px));
  border-radius: 16px;
  border:1px solid rgba(41,242,255,.28);
  background: linear-gradient(180deg, rgba(12,17,26,.96), rgba(5,6,10,.94));
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop{ background: rgba(0,0,0,.62); backdrop-filter: blur(3px); }

.dialog__form{ padding:14px; display:flex; flex-direction:column; gap:12px; }
.dialog__title{ margin:0; font-size:16px; text-transform:uppercase; letter-spacing:2px; }
.dialog__body{ color: rgba(232,247,255,.92); font-size:13px; line-height:1.45; font-family: var(--mono); }
.dialog__actions{ display:flex; justify-content:flex-end; gap:10px; }

.prompt-options{ display:flex; flex-direction:column; gap:10px; margin-top:6px; }
.option-row{ display:flex; align-items:center; gap:10px; }
.option-row input{ transform: translateY(1px); }

.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border:1px solid rgba(41,242,255,.30);
  border-radius:999px;
  padding:6px 10px;
  background: rgba(0,0,0,.15);
  font-size:12px;
  color: rgba(232,247,255,.92);
  font-family: var(--mono);
}
