:root {
  color-scheme: dark;
  --bg: #06080d;
  --surface: #0d141d;
  --surface-2: #121d2a;
  --surface-3: #090f17;
  --line: #26384a;
  --line-soft: rgba(130, 164, 193, .22);
  --text: #f3f7fb;
  --muted: #94a8b9;
  --primary: #48d6c6;
  --secondary: #7ea7ff;
  --accent: #f2c14e;
  --danger: #ff6b6b;
  --board-height: clamp(410px, min(calc(100svh - 252px), calc((100vw - 360px) / 1.354)), 840px);
  --board-width: calc(var(--board-height) * .677);
  --arena-gap: 4px;
  --overlay-width: clamp(146px, 8vw, 182px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.arkanoid-app {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(72, 214, 198, .055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(126, 167, 255, .05) 1px, transparent 1px),
    radial-gradient(circle at 18% 0%, rgba(242, 193, 78, .08), transparent 26%),
    var(--bg);
  background-size: 54px 54px, 54px 54px, auto, auto;
}

.arkanoid-topbar,
.arkanoid-ranking,
.arkanoid-board,
.arkanoid-overlay__panel,
.arkanoid-help__panel {
  border: 1px solid var(--line);
  background: rgba(13, 20, 29, .94);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .34);
}

.arkanoid-topbar {
  min-height: 88px;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border-radius: 8px;
}

.arkanoid-brand {
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.arkanoid-language-switcher {
  position: relative;
  flex: 0 0 auto;
}

.arkanoid-language-switcher summary {
  width: auto;
  min-width: 64px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text);
  font-size: .76rem;
  font-weight: 850;
  padding: 0 11px;
  list-style: none;
  cursor: pointer;
  outline: none;
}

.arkanoid-language-switcher summary::-webkit-details-marker {
  display: none;
}

.arkanoid-language-switcher summary::marker {
  content: "";
}

.arkanoid-language-switcher summary::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: .72;
  transition: transform .12s ease;
}

.arkanoid-language-switcher[open] summary::after {
  transform: rotate(180deg);
}

.arkanoid-language-switcher__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 190px;
  max-height: min(420px, calc(100svh - 140px));
  display: none;
  padding: 6px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 20, 29, .98);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .38);
}

.arkanoid-language-switcher[open] .arkanoid-language-switcher__menu {
  display: grid;
  gap: 3px;
}

.arkanoid-language-switcher__option {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--text);
  font-size: .82rem;
  text-decoration: none;
}

.arkanoid-language-switcher__option:hover,
.arkanoid-language-switcher__option.is-active {
  background: var(--surface-2);
}

.arkanoid-language-switcher__option span:first-child {
  color: var(--primary);
  font-weight: 900;
}

.arkanoid-language-switcher__option span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arkanoid-brand__mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 0 20%, #48d6c6 20% 40%, #7ea7ff 40% 60%, #f2c14e 60% 80%, #ff6b6b 80%),
    var(--surface-3);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}

.arkanoid-brand h1,
.arkanoid-brand p,
.arkanoid-ranking h2,
.arkanoid-board h2,
.arkanoid-ranking__empty {
  margin: 0;
}

.arkanoid-brand h1 {
  font-size: 1.55rem;
  line-height: 1.1;
  font-weight: 850;
  letter-spacing: 0;
}

.arkanoid-brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: .92rem;
}

.arkanoid-controls {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(514px, 600px) minmax(340px, 1fr);
  align-items: end;
  gap: 8px;
  justify-self: stretch;
}

.arkanoid-setup {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 96px minmax(252px, 296px);
  align-items: end;
  gap: 8px;
}

.arkanoid-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.arkanoid-field input,
.arkanoid-field select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.arkanoid-field small {
  color: #ffc4c4;
  font-size: .72rem;
  line-height: 1.25;
  text-transform: none;
}

.arkanoid-field small[hidden] {
  display: none;
}

.arkanoid-field input.is-invalid {
  border-color: var(--danger);
}

.arkanoid-field input:focus,
.arkanoid-field select:focus,
.arkanoid-button:focus-visible,
.arkanoid-language-switcher summary:focus-visible,
.arkanoid-help__close:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(72, 214, 198, .22);
}

.arkanoid-button {
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 850;
  line-height: 1.05;
  text-align: center;
  color: #041014;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, opacity .12s ease;
}

.arkanoid-button[hidden] {
  display: none;
}

.arkanoid-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.arkanoid-button:disabled {
  opacity: .54;
  cursor: not-allowed;
  filter: grayscale(.24);
  transform: none;
}

.arkanoid-button--primary {
  background: var(--primary);
}

.arkanoid-button--secondary {
  background: var(--secondary);
}

.arkanoid-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-self: end;
}

.arkanoid-actions .arkanoid-button {
  width: 100%;
  min-width: 0;
  padding: 0 10px;
}

.arkanoid-hud {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 8px;
  align-items: center;
  padding: 0;
}

.arkanoid-hud div {
  min-height: 42px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 7px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface-3);
}

.arkanoid-hud span,
.arkanoid-ranking__header span,
.arkanoid-board__header span {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.arkanoid-hud strong {
  font-size: 1.24rem;
  line-height: 1;
}

.arkanoid-layout {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 286px);
  gap: 12px;
  align-items: start;
}

.arkanoid-arena {
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-areas: "left right";
  grid-template-columns: var(--board-width) var(--board-width);
  gap: var(--arena-gap);
  align-items: start;
  justify-content: center;
  justify-self: center;
  max-width: 100%;
}

.arkanoid-board {
  width: var(--board-width);
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto;
  overflow: hidden;
  border-radius: 8px;
}

.arkanoid-board__header {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

.arkanoid-board h2 {
  font-size: .98rem;
  line-height: 1.2;
  font-weight: 850;
}

.arkanoid-board__canvas {
  width: var(--board-width);
  height: var(--board-height);
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--surface-3);
}

.arkanoid-board__canvas canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.arkanoid-board--left {
  grid-area: left;
  border-color: rgba(72, 214, 198, .46);
}

.arkanoid-board--right {
  grid-area: right;
  border-color: rgba(126, 167, 255, .46);
}

.arkanoid-ranking {
  justify-self: stretch;
  align-self: stretch;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 8px;
}

.arkanoid-ranking__header {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.arkanoid-ranking h2 {
  margin-top: 2px;
  font-size: 1.15rem;
  line-height: 1.1;
  font-weight: 850;
}

.arkanoid-ranking__header strong {
  min-width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 1.2rem;
}

.arkanoid-ranking__list {
  min-height: 0;
  margin: 0;
  padding: 8px 12px 12px 42px;
  overflow: auto;
}

.arkanoid-ranking__list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.arkanoid-ranking__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
}

.arkanoid-ranking__name {
  overflow: hidden;
  color: var(--text);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arkanoid-ranking__score {
  color: var(--primary);
  font-weight: 900;
}

.arkanoid-ranking__empty {
  padding: 12px 14px 14px;
  color: var(--muted);
}

.arkanoid-ranking__empty[hidden] {
  display: none;
}

.arkanoid-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--board-width) + var(--arena-gap) / 2 - var(--overlay-width) / 2);
  width: var(--overlay-width);
  z-index: 3;
  display: grid;
  align-self: stretch;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  pointer-events: none;
}

.arkanoid-overlay[hidden] {
  display: none;
}

.arkanoid-overlay__panel {
  width: 100%;
  max-width: var(--overlay-width);
  display: grid;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  pointer-events: auto;
}

.arkanoid-overlay__panel span {
  color: var(--muted);
  font-weight: 850;
  text-transform: uppercase;
}

.arkanoid-overlay__panel strong {
  font-size: clamp(1.9rem, 3.3vw, 2.7rem);
  line-height: 1;
}

.arkanoid-overlay__panel .arkanoid-button {
  width: 100%;
}

.arkanoid-help {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 5, 9, .68);
}

.arkanoid-help[hidden] {
  display: none;
}

.arkanoid-help__panel {
  width: min(520px, 100%);
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 8px;
}

.arkanoid-help__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.arkanoid-help__header h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.1;
}

.arkanoid-help__close {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  outline: none;
}

.arkanoid-help__body {
  display: grid;
  gap: 2px;
}

.arkanoid-help__group {
  display: grid;
  grid-template-columns: minmax(120px, .42fr) minmax(0, 1fr);
  gap: 8px 14px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.arkanoid-help__group:first-child {
  border-top: 0;
}

.arkanoid-help__group strong {
  grid-column: 1;
  min-height: 28px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
  line-height: 1.1;
  text-transform: uppercase;
}

.arkanoid-help__group span {
  grid-column: 2;
  min-height: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  line-height: 1.35;
}

.arkanoid-help kbd {
  min-width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-bottom-color: var(--primary);
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text);
  font-size: .78rem;
  font-weight: 900;
  line-height: 1;
  vertical-align: middle;
}

.arkanoid-help__panel .arkanoid-button {
  justify-self: end;
  min-width: 112px;
}

.screen-guard,
.device-guard {
  display: grid;
  gap: 3px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 107, 107, .5);
  border-radius: 8px;
  background: rgba(55, 18, 22, .9);
  color: var(--text);
}

.screen-guard[hidden],
.device-guard[hidden] {
  display: none;
}

.screen-guard strong,
.device-guard strong {
  font-size: .95rem;
}

.screen-guard span,
.device-guard span {
  color: #ffc4c4;
  font-size: .88rem;
}

@media (max-width: 1219px) {
  .arkanoid-topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .arkanoid-controls {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .arkanoid-hud {
    grid-column: 1 / -1;
  }

  .arkanoid-arena {
    grid-template-areas:
      "left"
      "status"
      "right";
    grid-template-columns: 1fr;
  }

  .arkanoid-overlay {
    grid-area: status;
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    width: 100%;
  }

  .arkanoid-overlay[hidden] {
    display: none;
  }

  .arkanoid-overlay__panel {
    max-width: 360px;
  }
}

@media (max-width: 1120px) {
  .arkanoid-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .arkanoid-ranking {
    max-height: 360px;
  }
}

@media (max-width: 1040px) {
  .arkanoid-topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .arkanoid-brand {
    min-width: 0;
  }

  .arkanoid-controls {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .arkanoid-hud {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .arkanoid-app {
    padding: 10px;
  }

  .arkanoid-topbar {
    align-items: stretch;
  }

  .arkanoid-setup {
    grid-template-columns: minmax(0, 1fr) 116px;
  }

  .arkanoid-actions {
    grid-column: 1 / -1;
  }

  .arkanoid-hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .arkanoid-arena {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .arkanoid-controls {
    grid-template-columns: 1fr;
  }

  .arkanoid-language-switcher {
    justify-self: start;
  }

  .arkanoid-help__group {
    grid-template-columns: 1fr;
  }

  .arkanoid-help__group strong,
  .arkanoid-help__group span {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 460px) {
  .arkanoid-brand {
    min-width: 0;
    flex-wrap: wrap;
  }

  .arkanoid-brand h1 {
    font-size: 1.32rem;
  }

  .arkanoid-setup {
    grid-template-columns: 1fr;
  }
}
