/* Stile "store di gioco": sfondo scuro, card spesse con bordo nero, pulsanti 3D.
   Design originale ispirato al genere: nessun asset o font di Supercell. */
:root {
  --bg-1: #0b1030;
  --bg-2: #171f5c;
  --panel: #1c2766;
  --panel-2: #26338a;
  --ink: #05081f;
  --text: #f4f6ff;
  --muted: #a9b3e6;
  --yellow: #ffc933;
  --yellow-d: #d49a00;
  --blue: #2f80ff;
  --green: #35d67f;
  --red: #ff4b5c;
  --purple: #a45bff;
  --radius: 18px;
  --font: "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-weight: 700;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 15% -10%, #3a4bd1 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 10%, #6a2fd1 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1) 70%);
  background-attachment: fixed;
  line-height: 1.45;
}
main { max-width: 1040px; margin: 0 auto; padding: 0 16px 32px; }
h1, h2, h3 { margin: 0; line-height: 1.1; letter-spacing: .3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* testo con contorno stile gioco */
.outline, h1, h2, .logo {
  text-shadow:
    -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink),
    0 3px 0 var(--ink), 0 -2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink);
}

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1040px; margin: 0 auto; padding: 14px 16px;
}
.logo { font-size: 28px; text-decoration: none; display: inline-flex; gap: 6px; font-style: italic; }
.logo-a { color: #fff; }
.logo-b { color: var(--yellow); }
.tagline { color: var(--muted); font-size: 13px; text-align: right; }

/* hero */
.hero { text-align: center; padding: 28px 0 8px; }
h1 { font-size: clamp(30px, 6vw, 52px); color: #fff; }
.lead { color: var(--muted); margin: 14px 0 22px; font-size: 17px; }
.tag-form { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.tag-input {
  display: flex; align-items: center; gap: 4px;
  background: var(--ink); border: 3px solid var(--ink); border-radius: 14px;
  padding: 0 14px; box-shadow: 0 4px 0 #000, inset 0 0 0 2px #2b377f;
  min-width: min(100%, 300px);
}
.tag-input:focus-within { box-shadow: 0 4px 0 #000, inset 0 0 0 2px var(--yellow); }
.hash { color: var(--yellow); font-size: 22px; }
.tag-input input {
  flex: 1; background: transparent; border: 0; color: #fff; font: inherit; font-size: 22px;
  padding: 14px 4px; text-transform: uppercase; letter-spacing: 2px; outline: none; width: 100%;
}
.tag-input input::placeholder { color: #55609f; }

.btn {
  font: inherit; font-size: 18px; cursor: pointer; color: #fff;
  background: var(--panel-2); border: 3px solid var(--ink); border-radius: 14px;
  padding: 12px 22px; box-shadow: 0 5px 0 var(--ink); transition: transform .08s, box-shadow .08s, filter .15s;
  text-shadow: 0 2px 0 var(--ink);
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible, select:focus-visible, input:focus-visible, .card:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.btn-primary { background: linear-gradient(180deg, #ffe066, var(--yellow)); color: #3a2600; text-shadow: none; box-shadow: 0 5px 0 var(--yellow-d), 0 5px 0 3px var(--ink); }
.btn-primary:active { box-shadow: 0 1px 0 var(--yellow-d), 0 1px 0 3px var(--ink); }
.btn[disabled] { opacity: .6; cursor: wait; }

.remember { display: inline-flex; gap: 8px; align-items: center; margin-top: 16px; color: var(--muted); font-size: 14px; cursor: pointer; }
.remember input { width: 18px; height: 18px; accent-color: var(--yellow); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.error {
  display: inline-block; margin: 16px auto 0; padding: 10px 16px; max-width: 520px;
  background: #4a1020; border: 3px solid var(--ink); border-radius: 12px; color: #ffd5da; font-size: 15px;
}

/* loading */
.loading { text-align: center; padding: 40px 0; color: var(--muted); }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 50%;
  border: 6px solid #2b377f; border-top-color: var(--yellow); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* blocchi */
.block { margin-top: 30px; }
.block h2 { font-size: 26px; margin-bottom: 14px; }
.block-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.block-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

.panel, .profile, .table-card, .advice, .card, dialog {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--ink), inset 0 2px 0 rgba(255,255,255,.12);
}

/* profilo */
.profile { margin-top: 24px; padding: 18px; }
.profile-top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-bottom: 16px; }
.pname { font-size: 30px; }
.pmeta { color: var(--muted); font-size: 14px; }
.lvl { background: var(--blue); border: 3px solid var(--ink); border-radius: 10px; padding: 2px 10px; font-size: 15px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: rgba(5,8,31,.45); border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; }
.stat .v { font-size: 24px; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.stat.warn .v { color: var(--yellow); }
.stat.good .v { color: var(--green); }
.stat.bad .v { color: var(--red); }

/* consigli */
.advice-list { display: grid; gap: 12px; }
.advice { padding: 14px 16px 14px 20px; position: relative; overflow: hidden; }
.advice::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--c, var(--muted)); }
.advice h3 { font-size: 19px; margin-bottom: 4px; }
.advice p { margin: 0; color: #dfe4ff; font-weight: 600; }
.lvl-high { --c: var(--red); } .lvl-mid { --c: var(--yellow); } .lvl-good { --c: var(--green); } .lvl-low { --c: #7480c8; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  font: inherit; font-size: 13px; cursor: pointer; color: #fff; background: rgba(5,8,31,.55);
  border: 2px solid var(--ink); border-radius: 999px; padding: 4px 12px;
}
.chip:hover { background: rgba(5,8,31,.85); }
.badge { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; padding: 2px 8px; border-radius: 8px; border: 2px solid var(--ink); background: var(--c, var(--muted)); color: #111; margin-left: 8px; vertical-align: middle; }

/* griglia brawler */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar input, .toolbar select {
  font: inherit; font-size: 15px; color: #fff; background: var(--ink); border: 3px solid var(--ink);
  border-radius: 12px; padding: 8px 12px; box-shadow: inset 0 0 0 2px #2b377f;
}
.brawler-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card {
  position: relative; padding: 12px 10px 12px; text-align: center; cursor: pointer; color: inherit; font: inherit;
  transition: transform .1s; width: 100%;
}
.card:hover { transform: translateY(-3px); }
.card:active { transform: translateY(2px); }
.icon-wrap {
  width: 84px; height: 84px; margin: 0 auto 8px; border-radius: 16px; overflow: hidden;
  background: var(--ink); border: 3px solid var(--ink); display: grid; place-items: center;
}
.icon-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.icon-fallback { font-size: 34px; color: var(--yellow); }
.card .nm { font-size: 15px; margin-bottom: 4px; overflow-wrap: anywhere; }
.card .tr { font-size: 14px; color: var(--yellow); }
.card .sub { display: flex; justify-content: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 2px solid var(--ink); background: rgba(5,8,31,.55); }
.pill.good { background: #1f7a4d; } .pill.bad { background: #8a2433; } .pill.up { background: #8a6300; }
.pwr { position: absolute; top: 6px; left: 6px; background: var(--blue); border: 2px solid var(--ink); border-radius: 8px; padding: 0 7px; font-size: 13px; }
.pwr.max { background: var(--purple); }

/* tabelle */
.table-card { padding: 6px 14px; }
.row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 2px solid rgba(5,8,31,.5); font-size: 14px; }
.row:last-child { border-bottom: 0; }
.row .g { color: var(--muted); font-size: 12px; }
.bar { width: 90px; height: 10px; background: var(--ink); border-radius: 6px; overflow: hidden; border: 2px solid var(--ink); }
.bar > i { display: block; height: 100%; width: var(--w, 0%); background: var(--c, var(--green)); }
.empty { color: var(--muted); padding: 14px 0; }
.note { color: var(--muted); font-size: 13px; margin-top: 24px; }
.again { text-align: center; margin-top: 18px; }

/* dialog */
dialog { color: var(--text); padding: 18px; width: min(560px, calc(100vw - 24px)); max-height: 88vh; overflow: auto; }
dialog::backdrop { background: rgba(3,5,20,.75); }
.dlg-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.dlg-head .icon-wrap { margin: 0; width: 72px; height: 72px; flex: none; }
.dlg-head h3 { font-size: 26px; }
.dlg-sec { margin-top: 14px; }
.dlg-sec h4 { margin: 0 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; }
.dlg-sec ul { margin: 0; padding-left: 18px; font-weight: 600; }
.tip { padding: 10px 12px 10px 16px; margin-top: 8px; border-radius: 12px; border: 2px solid var(--ink); background: rgba(5,8,31,.45); border-left: 8px solid var(--c, var(--muted)); font-weight: 600; font-size: 14px; }
.dlg-close { margin-top: 18px; width: 100%; }

footer { max-width: 1040px; margin: 20px auto 0; padding: 20px 16px 40px; color: var(--muted); font-size: 12px; font-weight: 600; }
footer p { margin: 0 0 8px; }

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