:root {
  color-scheme: dark;
  --bg: #070b13;
  --panel: rgba(13, 19, 31, 0.82);
  --panel-strong: rgba(6, 10, 18, 0.92);
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f7f9fc;
  --muted: #a9b5c6;
  --soft: #d6dce7;
  --cyan: #5ee7ff;
  --pink: #ff5277;
  --amber: #ffd84a;
  --green: #2fd577;
  --blue: #2e8ae8;
  --purple: #a14df0;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.46);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(120deg, rgba(255, 82, 119, 0.18), transparent 28%),
    linear-gradient(210deg, rgba(94, 231, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #111824 0%, var(--bg) 44%, #05070c 100%);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(94, 231, 255, 0.42);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px clamp(14px, 4vw, 56px);
  background: rgba(5, 9, 16, 0.84);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg, #ff475f, #ffd84a 36%, #2fd577 62%, #2e8ae8);
  box-shadow: inset 0 2px 10px rgba(255,255,255,.22), 0 10px 28px rgba(0,0,0,.28);
  transform: rotate(-8deg);
}

.brand-mark span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.96);
  box-shadow:
    -8px -8px 0 rgba(255,255,255,.9),
    8px 8px 0 rgba(255,255,255,.9),
    8px -8px 0 rgba(0,0,0,.26),
    -8px 8px 0 rgba(0,0,0,.26);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: .92rem;
}

.site-header nav a:hover { color: var(--text); }

main {
  width: min(1360px, calc(100% - 28px));
  margin: 0 auto;
}

.first-screen {
  min-height: calc(100svh - 58px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 14px 0 20px;
}

.app-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.03;
  letter-spacing: 0;
}

h1 { font-size: clamp(2rem, 5vw, 4.65rem); }
h2 { font-size: clamp(1.12rem, 2vw, 1.55rem); }
p { color: var(--muted); line-height: 1.58; }
.app-subtitle {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--soft);
  font-size: clamp(.94rem, 1.35vw, 1.08rem);
}

.intro-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.intro-badges span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: var(--soft);
  font-weight: 800;
  font-size: .85rem;
}

.game-console {
  display: grid;
  grid-template-columns: minmax(230px, 0.72fr) minmax(430px, 1.55fr) minmax(250px, 0.78fr);
  gap: 14px;
  align-items: stretch;
  min-height: min(620px, calc(100svh - 205px));
}

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.035));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.controls,
.dice-stage,
.share-card,
.history-preview {
  min-width: 0;
  min-height: 0;
}

.controls,
.share-card,
.history-preview {
  padding: 14px;
}

.panel-heading,
.stage-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-heading span,
.stage-topline span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
}

.field-label,
legend {
  display: block;
  margin-bottom: 8px;
  color: var(--soft);
  font-weight: 850;
  font-size: .9rem;
}

.stepper {
  display: grid;
  grid-template-columns: 44px minmax(72px, 1fr) 44px;
  gap: 8px;
}

.stepper button,
.preset-row button,
.secondary-button,
.icon-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: rgba(255,255,255,.07);
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.stepper button:hover,
.preset-row button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255,255,255,.1);
}

.stepper input,
.copy-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: rgba(0,0,0,.25);
  font-weight: 900;
}

.stepper input {
  padding: 10px 8px;
  text-align: center;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin: 9px 0 14px;
}

.preset-row button {
  min-height: 34px;
  color: var(--muted);
  font-size: .86rem;
}

.color-picker {
  margin: 0;
  padding: 0;
  border: 0;
}

.color-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.color-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: rgba(255,255,255,.07);
}

.color-pill[aria-pressed="false"] {
  opacity: .45;
  background: rgba(0,0,0,.18);
}

.color-left {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  font-weight: 820;
  font-size: .88rem;
}

.dot,
.summary-swatch {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  border-radius: 6px;
  display: inline-block;
  border: 2px solid rgba(255,255,255,.78);
}

.red { background: #ff475f; }
.orange { background: #ff941f; }
.yellow { background: #ffd84a; }
.green { background: #2fd577; }
.blue { background: #2e8ae8; }
.purple { background: #a14df0; }

.hint {
  margin: 8px 0 13px;
  font-size: .78rem;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.secondary-button {
  padding: 9px 10px;
  font-weight: 820;
}

.dice-stage {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.02)),
    radial-gradient(circle at 50% 0%, rgba(94, 231, 255, .13), transparent 45%),
    var(--panel-strong);
}

.stage-topline {
  margin-bottom: 10px;
}

.dice-grid {
  flex: 1 1 auto;
  min-height: 170px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap: 10px;
  align-content: start;
  padding: 4px;
  overflow: auto;
  scrollbar-width: thin;
}

.dice-grid.large {
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 7px;
}

.dice-grid.huge {
  grid-template-columns: repeat(auto-fit, minmax(26px, 1fr));
  gap: 6px;
}

.die {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 12px;
  box-shadow: inset 0 7px 13px rgba(255,255,255,.13), inset 0 -12px 18px rgba(0,0,0,.19), 0 10px 24px rgba(0,0,0,.24);
  animation: pop .25s ease both;
}

.die::before {
  content: "";
  width: 16%;
  height: 16%;
  border-radius: 50%;
  background: rgba(255,255,255,.88);
  box-shadow:
    -115% -115% 0 rgba(255,255,255,.75),
    115% 115% 0 rgba(0,0,0,.24);
}

.die::after {
  content: attr(data-label);
  position: absolute;
  inset: auto 3px 3px;
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: rgba(255,255,255,.95);
  font-size: 10px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0,0,0,.58);
}

.rolling .die { animation: shake .34s linear infinite; }

.summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  margin: 10px 0 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(0,0,0,.23);
}

.summary-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255,255,255,.055);
  color: var(--soft);
  font-weight: 850;
  font-size: .88rem;
}

.summary-item strong {
  color: var(--text);
  font-size: 1.08rem;
}

.roll-button {
  width: min(390px, 100%);
  min-height: 58px;
  margin: 12px auto 8px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, #ff475f, #ff941f 52%, #ffd84a);
  box-shadow: 0 18px 46px rgba(255, 71, 95, .26);
  font-size: 1.08rem;
  font-weight: 1000;
  letter-spacing: .04em;
}

.status {
  min-height: 24px;
  margin: 0;
  text-align: center;
  color: var(--soft);
  font-size: .88rem;
}

.side-panel {
  display: grid;
  grid-template-rows: minmax(0, .95fr) minmax(0, 1.05fr);
  gap: 14px;
  min-height: 0;
}

.compact-copy {
  margin: 0 0 10px;
  font-size: .82rem;
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 8px;
}

.copy-row input {
  padding: 10px;
  color: var(--soft);
  font-size: .76rem;
}

.icon-button {
  min-width: 0;
  padding: 8px;
  font-weight: 850;
}

.qr-note {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed rgba(94, 231, 255, .32);
  border-radius: 13px;
  background: rgba(94, 231, 255, .07);
  color: var(--muted);
  font-size: .78rem;
}

.qr-note strong {
  color: var(--text);
  font-size: .82rem;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 100%;
  overflow: auto;
  scrollbar-width: thin;
}

.history-list > p {
  margin: 0;
  font-size: .85rem;
}

.history-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(0,0,0,.22);
}

.history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-item code {
  color: var(--cyan);
  font-size: .76rem;
}

.history-meta,
.history-colors {
  color: var(--muted);
  font-size: .76rem;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 30px 0;
}

.content-grid article,
.seo-copy {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.055);
  box-shadow: var(--shadow);
}

.content-grid article {
  padding: 22px;
}

.content-grid h2 {
  font-size: 1.25rem;
}

.seo-copy {
  padding: clamp(18px, 3vw, 34px);
  margin: 30px 0;
}

.seo-copy h2 {
  margin-bottom: 16px;
}

.seo-copy details {
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.seo-copy summary {
  cursor: pointer;
  font-weight: 880;
  font-size: 1.02rem;
}

.site-footer {
  padding: 30px 18px 42px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.site-footer p { margin: 0; }

body.presentation {
  overflow: hidden;
}

body.presentation .site-header,
body.presentation .app-intro,
body.presentation .controls,
body.presentation .side-panel,
body.presentation .content-grid,
body.presentation .seo-copy,
body.presentation .site-footer {
  display: none;
}

body.presentation main {
  width: 100%;
}

body.presentation .first-screen {
  min-height: 100vh;
  padding: 0;
}

body.presentation .game-console {
  display: block;
  min-height: 100vh;
}

body.presentation .dice-stage {
  min-height: 100vh;
  border-radius: 0;
  border: 0;
}

body.presentation .dice-grid {
  grid-template-columns: repeat(auto-fit, minmax(66px, 1fr));
}

body.presentation .dice-grid.huge {
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
}

body.presentation .roll-button {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 220px;
}

@keyframes pop {
  from { transform: scale(.85); opacity: .35; }
  to { transform: scale(1); opacity: 1; }
}

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

@media (max-width: 1100px) {
  .first-screen {
    justify-content: flex-start;
  }

  .app-intro {
    grid-template-columns: 1fr;
  }

  .intro-badges {
    justify-content: flex-start;
  }

  .game-console {
    grid-template-columns: minmax(230px, .72fr) minmax(0, 1.28fr);
    min-height: auto;
  }

  .dice-stage {
    min-height: 480px;
  }

  .side-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }
}

@media (max-width: 720px) {
  main {
    width: min(100% - 18px, 1360px);
  }

  .site-header nav {
    display: none;
  }

  .first-screen {
    padding-top: 12px;
  }

  .game-console,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .dice-stage {
    order: -1;
    min-height: 430px;
  }

  .color-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .color-pill {
    justify-content: center;
  }

  .color-pill > span:last-child {
    display: none;
  }

  .control-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .secondary-button {
    min-height: 42px;
    padding: 8px 6px;
    font-size: .78rem;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  h1 { font-size: 2rem; }
  .app-subtitle { font-size: .9rem; }
  .intro-badges span { min-height: 32px; font-size: .76rem; }
  .dice-grid { grid-template-columns: repeat(auto-fit, minmax(42px, 1fr)); }
  .dice-grid.large { grid-template-columns: repeat(auto-fit, minmax(30px, 1fr)); }
  .dice-grid.huge { grid-template-columns: repeat(auto-fit, minmax(23px, 1fr)); }
  .summary-item { font-size: .78rem; }
  .roll-button { min-height: 54px; }
}
