:root {
  color-scheme: dark;
  --ink: #eef4ea;
  --muted: #9db1a1;
  --line: rgba(238, 244, 234, 0.14);
  --panel: #111b19;
  --panel-2: #172521;
  --accent: #f0c24b;
  --accent-2: #40c790;
  --danger: #f06a5f;
  --grass-a: #246a3d;
  --grass-b: #2d7847;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #07100e;
  color: var(--ink);
}

button,
select,
.menu-row a {
  font: inherit;
}

button,
.menu-row a {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #20312d;
  color: var(--ink);
  min-height: 42px;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover,
button.active,
.menu-row a:hover {
  border-color: rgba(240, 194, 75, 0.7);
  background: #2a3f38;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border: 0;
  background: var(--accent);
  color: #1d1604;
  font-weight: 800;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(420px, 1fr) 280px;
  height: 100%;
  min-height: 0;
}

.panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: linear-gradient(180deg, var(--panel), #0c1412);
  border-color: var(--line);
}

.panel-left {
  border-right: 1px solid var(--line);
}

.panel-right {
  border-left: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-2);
  color: #04100c;
  font-weight: 900;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
  line-height: 1;
}

p,
small,
.field span,
.status-line {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #20312d;
  color: var(--ink);
}

.button-row,
.menu-row,
.actions,
.tabs {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
}

.menu-row {
  grid-template-columns: 1fr 1fr;
}

.menu-row a {
  display: grid;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.actions,
.tabs {
  grid-template-columns: repeat(3, 1fr);
}

.tabs {
  grid-template-columns: repeat(2, 1fr);
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.scoreboard div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.scoreboard div:last-child {
  justify-content: flex-end;
}

.scoreboard span {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}

.scoreboard time {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.touch-pad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left down right";
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
}

.touch-pad button {
  aspect-ratio: 1 / 1;
  min-height: 0;
  font-size: 1.15rem;
  font-weight: 900;
}

.touch-pad [data-dir="up"] {
  grid-area: up;
}

.touch-pad [data-dir="left"] {
  grid-area: left;
}

.touch-pad [data-dir="down"] {
  grid-area: down;
}

.touch-pad [data-dir="right"] {
  grid-area: right;
}

.key-guide {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.key-guide span {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(32, 49, 45, 0.52);
}

.key-guide strong {
  color: var(--accent);
  font-size: 0.9rem;
}

.pitch-wrap {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 14px;
  background: #091411;
}

canvas {
  display: block;
  width: min(100%, calc((100vh - 28px) * 1.548));
  max-height: calc(100vh - 28px);
  aspect-ratio: 960 / 620;
  border: 1px solid rgba(238, 244, 234, 0.24);
  border-radius: 6px;
  background: var(--grass-a);
  image-rendering: pixelated;
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.35);
}

.pitch-wrap .actions {
  position: absolute;
  right: 28px;
  bottom: 28px;
  width: min(360px, calc(100% - 56px));
  z-index: 5;
}

.pitch-wrap .actions button {
  border-color: rgba(238, 244, 234, 0.32);
  background: rgba(17, 27, 25, 0.88);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(4px);
}

.status-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 24px;
  font-size: 0.9rem;
}

.player-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.player-card span {
  display: grid;
  grid-row: span 2;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
  color: #1d1604;
  font-weight: 900;
}

.player-card strong {
  overflow-wrap: anywhere;
}

.meter-list {
  display: grid;
  gap: 10px;
}

.meter {
  display: grid;
  grid-template-columns: 74px 1fr 34px;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.meter-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #0b1512;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.lineup {
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lineup li {
  display: grid;
  grid-template-columns: 34px 1fr 42px;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.lineup button {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 34px 1fr 42px;
  gap: 8px;
  align-items: center;
  min-height: 0;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  box-shadow: none;
}

.lineup button:hover,
.lineup button.active {
  background: transparent;
  color: var(--ink);
}

.lineup strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

@media (max-width: 1040px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    min-height: 100%;
    height: auto;
  }

  .panel {
    border: 0;
  }

  .panel-left {
    order: 2;
    gap: 10px;
    padding: 12px;
  }

  .pitch-wrap {
    order: 1;
    min-height: 52vh;
    padding: 10px;
  }

  .panel-right {
    order: 3;
    max-height: 42vh;
    overflow: hidden;
    padding: 12px;
  }

  canvas {
    width: 100%;
    max-height: none;
  }

  .brand {
    order: 1;
  }

  .touch-pad {
    order: 2;
    max-width: 260px;
    margin-top: 0;
    align-self: center;
    width: 100%;
  }

  .key-guide {
    order: 3;
  }

  .panel-left .field {
    order: 4;
  }

  .button-row {
    order: 5;
  }

  .menu-row {
    order: 6;
  }

  .scoreboard {
    order: 7;
  }

  .pitch-wrap .actions {
    right: 10px;
    bottom: 10px;
    width: auto;
    grid-template-columns: repeat(3, minmax(64px, 84px));
  }

  .pitch-wrap .actions button {
    min-height: 38px;
    padding: 0 8px;
    font-size: 0.82rem;
  }
}
