* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --playfield-width: 100vw;
  --side-panel-width: 0px;
  --ink: #f2f4ff;
  --muted: #9aa7c5;
  --panel: #0c101b;
  --panel-2: #121827;
  --line: #2d354d;
  --cyan: #7af0ff;
  --amber: #ffd166;
  --green: #66f0a6;
  --rose: #ff7c9a;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(122, 240, 255, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 209, 102, 0.025) 1px, transparent 1px),
    #05070d;
  background-size: 40px 40px, 56px 56px, auto;
  color: #d8d8e8;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  user-select: none;
}

.main-menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(122, 240, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 209, 102, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(5, 7, 13, 0.96), rgba(10, 13, 22, 0.94)),
    #05070d;
  background-size: 52px 52px, 52px 52px, auto, auto;
}

.main-menu.is-hidden {
  display: none;
}

.main-menu-panel {
  width: min(620px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(122, 240, 255, 0.055), transparent 88px),
    linear-gradient(135deg, rgba(255, 209, 102, 0.055), transparent 180px),
    var(--panel);
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 30px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.main-menu-panel::before,
.main-menu-panel::after {
  content: "";
  position: absolute;
  width: 54px;
  height: 54px;
  pointer-events: none;
}

.main-menu-panel::before {
  top: 10px;
  left: 10px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
}

.main-menu-panel::after {
  right: 10px;
  bottom: 10px;
  border-right: 2px solid var(--amber);
  border-bottom: 2px solid var(--amber);
}

.menu-kicker {
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.menu-title {
  margin-top: 8px;
  color: var(--ink);
  font-size: 42px;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(122, 240, 255, 0.22);
}

.menu-subtitle {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.menu-actions {
  margin-top: 24px;
  display: grid;
  gap: 10px;
}

.menu-footer {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid rgba(122, 240, 255, 0.12);
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.04em;
  line-height: 1.55;
  color: rgba(216, 216, 232, 0.42);
}

.menu-footer a {
  color: rgba(216, 216, 232, 0.62);
  text-decoration: none;
  border-bottom: 1px solid rgba(122, 240, 255, 0.22);
  transition: color 120ms ease, border-color 120ms ease;
}

.menu-footer a:hover,
.menu-footer a:focus {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
  outline: none;
}

.menu-actions.is-hidden {
  display: none;
}

.menu-button {
  min-height: 44px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel-2);
  color: #d8d8e8;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0 14px;
  text-align: left;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.28);
}

.menu-button:hover,
.menu-button.is-listening,
.menu-button.is-focused,
.menu-button:focus-visible {
  border-color: var(--cyan);
  color: #ffffff;
  outline: none;
  background:
    linear-gradient(90deg, rgba(122, 240, 255, 0.14), transparent 72%),
    #151d2f;
}

.menu-button.is-primary {
  border-color: var(--cyan);
  color: #ffffff;
  background:
    linear-gradient(90deg, rgba(122, 240, 255, 0.18), rgba(255, 209, 102, 0.08)),
    #172338;
}

.menu-button.is-small {
  min-height: 34px;
  font-size: 12px;
}

.menu-button.is-locked {
  color: var(--muted);
  cursor: default;
}

.language-picker {
  border: 1px solid #24283a;
  background: #0b0f19;
  padding: 6px;
  display: grid;
  gap: 6px;
}

.language-picker.is-hidden {
  display: none;
}

.language-option {
  min-height: 34px;
  border: 1px solid #24283a;
  background: #111624;
  color: #d8d8e8;
  font: inherit;
  font-size: 12px;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.language-option:hover,
.language-option.is-focused,
.language-option:focus-visible {
  border-color: var(--cyan);
  color: #ffffff;
  outline: none;
}

.language-option.is-selected {
  color: var(--amber);
}

.controls-panel {
  margin-top: 22px;
  border-top: 1px solid #1f2436;
  padding-top: 18px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.controls-panel.is-hidden {
  display: none;
}

.controls-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
}

.controls-title {
  color: var(--ink);
  font-size: 18px;
}

.controls-hint {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.controls-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

#controls-reset {
  flex: 0 0 auto;
  margin-top: 12px;
}

.control-row {
  min-height: 38px;
  border: 1px solid #24283a;
  background: #111421;
  display: grid;
  grid-template-columns: 1fr 120px;
  align-items: stretch;
  gap: 10px;
  padding: 6px 10px;
}

.control-name {
  align-self: center;
  color: #d8d8e8;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-key {
  justify-self: stretch;
  align-self: center;
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 0 10px;
  text-align: center;
}

.device-block,
.cinematic-overlay,
.rules-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.device-block {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(122, 240, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 124, 154, 0.055) 1px, transparent 1px),
    #05070d;
  background-size: 46px 46px, 46px 46px, auto;
}

.device-block.is-hidden,
.cinematic-overlay.is-hidden,
.rules-overlay.is-hidden {
  display: none;
}

.device-block-panel,
.rules-panel {
  width: min(640px, calc(100vw - 32px));
  border: 1px solid #344057;
  background:
    linear-gradient(180deg, rgba(122, 240, 255, 0.06), transparent 110px),
    linear-gradient(135deg, rgba(255, 124, 154, 0.055), transparent 220px),
    #0b101b;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 30px;
}

.device-block-kicker,
.rules-kicker {
  color: var(--cyan);
  font-size: 11px;
  text-transform: uppercase;
}

.device-block h2,
.rules-panel h2 {
  margin-top: 9px;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.1;
}

.device-block p,
.rules-panel p {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.cinematic-overlay {
  display: grid;
  place-items: center;
  background: #020309;
}

.story-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background:
    linear-gradient(90deg, rgba(122, 240, 255, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 209, 102, 0.045) 1px, transparent 1px),
    #05070d;
  background-size: 52px 52px, 52px 52px, auto;
}

.cinematic-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.82);
}

.cinematic-caption {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  min-width: min(420px, calc(100vw - 42px));
  border: 1px solid rgba(122, 240, 255, 0.28);
  background: rgba(8, 12, 21, 0.78);
  color: #dfeeff;
  padding: 12px 16px;
  text-align: center;
  font-size: 12px;
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.45);
}

.rules-overlay {
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 45%, rgba(122, 240, 255, 0.08), transparent 320px),
    rgba(3, 4, 10, 0.82);
}

.rules-continue {
  margin-top: 20px;
  color: var(--amber);
  font-size: 13px;
}

/* Layout principale: HUD top, area canvas, HUD bottom. */
#stage {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: 68px 1fr 78px;
  grid-template-columns: 1fr;
}

.hud {
  background: transparent;
  border: 0;
  display: flex;
  justify-content: center;
}

.hud-row {
  width: var(--playfield-width);
  max-width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 18px;
  background: transparent;
  border: 0;
  box-shadow: none;
  font-size: 12px;
  letter-spacing: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.hud-card {
  min-height: 42px;
  border: 1px solid #29324a;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    #101624;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  box-shadow: inset 0 1px 0 rgba(122, 240, 255, 0.055);
}

.hud-card.is-wide {
  min-width: 154px;
}

.hud-row::-webkit-scrollbar,
.hud-bottom-row::-webkit-scrollbar {
  display: none;
}

.hud-label {
  color: var(--muted);
}

.hud-hearts {
  color: var(--rose);
  font-size: 17px;
  text-shadow: 0 0 10px rgba(255, 124, 154, 0.26);
}

.hud-empty {
  color: #34384f;
}

.hud-value {
  color: var(--amber);
}

.super-meter {
  display: inline-block;
  width: 96px;
  height: 10px;
  border: 1px solid #39435e;
  background: #080b13;
  overflow: hidden;
}

.super-meter-fill {
  display: block;
  height: 100%;
  width: var(--super-fill, 0%);
  background: linear-gradient(90deg, var(--cyan), var(--amber));
  box-shadow: 0 0 12px rgba(122, 240, 255, 0.32);
}

.hud-card.is-super-ready {
  border-color: rgba(255, 209, 102, 0.68);
}

.hud-card.is-super-ready .hud-value {
  color: #fff4a6;
}

.hud-card.is-super-ready .super-meter {
  border-color: rgba(255, 209, 102, 0.78);
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.18);
}

.hud-card.is-super-pulse {
  animation: super-ready-card 0.45s ease-out 2;
}

.hud-card.is-super-pulse .super-meter-fill {
  animation: super-ready-fill 0.45s ease-out 2;
}

@keyframes super-ready-card {
  0% { box-shadow: inset 0 1px 0 rgba(122, 240, 255, 0.055), 0 0 0 rgba(255, 209, 102, 0); }
  45% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 18px rgba(255, 209, 102, 0.34); }
  100% { box-shadow: inset 0 1px 0 rgba(122, 240, 255, 0.055), 0 0 0 rgba(255, 209, 102, 0); }
}

@keyframes super-ready-fill {
  0% { filter: brightness(1); }
  45% { filter: brightness(1.75); }
  100% { filter: brightness(1); }
}

.hud-bottom-panel {
  width: var(--playfield-width);
  max-width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  padding: 0 18px;
}

.hud-bottom-row {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.hud-slot {
  min-width: 92px;
  height: 42px;
  border: 1px solid #29314a;
  background:
    linear-gradient(180deg, rgba(122, 240, 255, 0.045), transparent),
    #101522;
  display: grid;
  grid-template-columns: 24px 1fr 24px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  color: #d8d8e8;
  font-size: 12px;
}

.hud-slot-key {
  color: var(--muted);
}

.hud-slot-count {
  color: var(--amber);
  text-align: right;
}

.ability-chip {
  height: 30px;
  min-width: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #29314a;
  background:
    linear-gradient(180deg, rgba(122, 240, 255, 0.045), transparent),
    #101522;
  padding: 0 9px;
  font-size: 11px;
  white-space: nowrap;
}

.ability-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ability-key {
  color: var(--cyan);
}

.ability-status {
  color: var(--amber);
}

.ability-status.is-ready {
  color: var(--green);
}

.ability-status.is-cooldown {
  color: #ffbd68;
}

#canvas-wrap {
  position: relative;
  background: transparent;
  overflow: hidden;
  min-height: 0; /* permette al canvas di ridursi nel grid */
}

.ability-side-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--side-panel-width);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  pointer-events: none;
  z-index: 4;
}

.ability-side-panel.is-hidden {
  display: none;
}

.ability-side-list {
  width: 100%;
  max-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: stretch;
}

.ability-side-panel .ability-chip {
  width: clamp(76px, calc(var(--side-panel-width) - 8px), 220px);
  height: auto;
  min-height: 44px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name name"
    "key status";
  gap: 4px 8px;
  padding: 7px 8px;
  white-space: normal;
}

.ability-side-panel .ability-name {
  grid-area: name;
  line-height: 1.15;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ability-side-panel .ability-key {
  grid-area: key;
  font-size: 10px;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ability-side-panel .ability-status {
  grid-area: status;
  justify-self: end;
  font-size: 10px;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: right;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

.shop-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(90deg, rgba(122, 240, 255, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 209, 102, 0.035) 1px, transparent 1px),
    rgba(3, 4, 10, 0.72);
  background-size: 44px 44px, 44px 44px, auto;
  z-index: 20;
}

.shop-overlay.is-hidden {
  display: none;
}

.shop-panel {
  width: min(620px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 32px));
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(122, 240, 255, 0.045), transparent 96px),
    var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.shop-header {
  min-height: 72px;
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #1f2436;
}

.shop-title {
  color: var(--ink);
  font-size: 18px;
}

.shop-subtitle {
  margin-top: 6px;
  color: #c0cce6;
  font-size: 13px;
  line-height: 1.5;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shop-quote {
  position: relative;
  padding: 6px 10px 6px 14px;
  border-left: 2px solid var(--cyan);
  color: #dde6f8;
  font-style: italic;
  line-height: 1.5;
}

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

.shop-meta-chip {
  border: 1px solid #2c3349;
  background: #131826;
  color: #aebbd6;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
}

.shop-meta-chip:last-child {
  color: var(--amber);
  border-color: #4a3d1a;
}

.shop-close {
  width: 34px;
  height: 34px;
  border: 1px solid #30364c;
  background: #151827;
  color: #d8d8e8;
  font: inherit;
  cursor: pointer;
}

.shop-close:hover {
  border-color: var(--cyan);
  color: #ffffff;
}

.shop-list {
  overflow-y: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.shop-item {
  min-height: 74px;
  border: 1px solid #24283a;
  background: #111421;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}

.shop-item.is-selected {
  border-color: var(--cyan);
  background:
    linear-gradient(90deg, rgba(122, 240, 255, 0.11), transparent),
    #151c2e;
}

.shop-item.is-selected .shop-item-title {
  color: #ffffff;
}

.shop-item-main {
  min-width: 0;
}

.shop-item-title {
  color: var(--ink);
  font-size: 14px;
}

.shop-item-desc {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.shop-item-meta {
  margin-top: 6px;
  color: var(--amber);
  font-size: 12px;
}

.shop-buy {
  min-width: 96px;
  height: 36px;
  border: 1px solid #3a425d;
  background: #172237;
  color: #f0f3ff;
  font: inherit;
  cursor: pointer;
}

.shop-buy:hover:not(:disabled) {
  border-color: var(--cyan);
}

.shop-buy:disabled {
  cursor: default;
  color: #69728c;
  background: #10121d;
}

.shop-feedback {
  min-height: 44px;
  padding: 12px 18px;
  border-top: 1px solid #1f2436;
  color: #c0cce6;
  font-size: 13px;
  line-height: 1.5;
}

.shop-feedback.is-ok {
  color: var(--green);
}

.shop-feedback.is-error {
  color: #ff8a5c;
}
