:root {
  --bg-a: #f8f2e9;
  --bg-b: #d9e6f2;
  --panel: #fcfaf4;
  --line: #c8b89b;
  --text: #232321;
  --muted: #5f5a4e;
  --accent: #1763a8;
  --accent-strong: #0f4f88;
  --danger: #8d2e2e;
  --felt-a: #0f6a3e;
  --felt-b: #0d5b35;
  --wood-a: #6c4327;
  --wood-b: #4d2f1c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  color: var(--text);
  font-family: "Avenir Next", "Trebuchet MS", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(23, 99, 168, 0.16), transparent 38%),
    radial-gradient(circle at 90% 12%, rgba(141, 46, 46, 0.13), transparent 36%),
    linear-gradient(160deg, var(--bg-a), var(--bg-b));
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: clamp(10px, 2.4vw, 18px);
}

.app-shell {
  width: min(1220px, 100%);
  height: 100%;
  max-height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 10px;
}

.controls,
.hud-grid,
.table-stage,
.help-links-bottom,
.status-line {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(33, 25, 16, 0.12);
}

.help-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.help-links-bottom {
  padding: 10px 12px;
}

.help-links a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  border: 1px solid #b7cbe0;
  background: #f5fbff;
  border-radius: 999px;
  padding: 7px 11px;
  white-space: nowrap;
}

.help-links a:hover {
  background: #e8f4ff;
}

.controls {
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.control-field {
  display: grid;
  gap: 5px;
}

.control-field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.control-field select,
.control-field input[type="range"],
.button-row button {
  font: inherit;
}

.control-field select {
  height: 38px;
  border-radius: 9px;
  border: 1px solid #b8c7d1;
  padding: 0 10px;
  background: #fff;
}

.power-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

#powerRange {
  width: 100%;
}

#powerRange:disabled {
  opacity: 0.9;
  cursor: default;
}

#powerValue {
  min-width: 56px;
  text-align: right;
  font-weight: 700;
  color: var(--accent-strong);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.button-row button {
  border: 1px solid #b7b39b;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  background: #fefdf8;
  color: #2e2b25;
  cursor: pointer;
}

.button-row button:hover:enabled {
  background: #f6f0dd;
}

.button-row button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#shootBtn {
  border-color: #89aed1;
  background: #e8f3ff;
  color: #164673;
}

#shootBtn:hover:enabled {
  background: #d8ebff;
}

.hud-grid {
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.hud-card {
  border: 1px solid #d7cbb8;
  border-radius: 11px;
  padding: 7px 8px;
  background: #fffefa;
  display: grid;
  gap: 2px;
  min-height: 0;
}

.hud-card span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.hud-card strong {
  font-size: clamp(14px, 2.8vw, 18px);
  color: #2b251f;
}

.table-stage {
  min-height: 0;
  padding: 8px;
  background:
    linear-gradient(180deg, #f9f7f2, #f2ebdf);
  display: flex;
  justify-content: center;
  align-items: center;
}

#tableCanvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  aspect-ratio: 25 / 14;
  display: block;
  border-radius: 10px;
  border: 1px solid #b89b79;
  background: #0f6a3e;
  touch-action: none;
  cursor: crosshair;
}

.status-line {
  margin: 0;
  padding: 12px 14px;
  min-height: 48px;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: #2d2a24;
  border-color: #d7ccb8;
}

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

  .button-row {
    justify-content: flex-start;
  }

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

@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  .help-links {
    width: 100%;
  }

  .help-links a {
    flex: 1;
    text-align: center;
  }

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

  .status-line {
    min-height: 60px;
    font-size: 13px;
  }
}
