:root {
  --panel-width: 290px;
  --board-desktop: min(86vh, calc(100vw - var(--panel-width) - 72px));
  --bg: #16120d;
  --panel: #241a12;
  --panel-soft: #302217;
  --line: rgba(61, 34, 16, 0.82);
  --text: #f6ead8;
  --muted: #d2b994;
  --accent: #d7a85b;
  --accent-soft: rgba(215, 168, 91, 0.22);
  --danger: #b84a3a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: radial-gradient(circle at 35% 25%, #332415 0%, var(--bg) 58%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  overscroll-behavior: none;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, var(--board-desktop)) var(--panel-width);
  justify-content: center;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
}

.board-section {
  width: var(--board-desktop);
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#board {
  display: block;
  width: var(--board-desktop);
  height: var(--board-desktop);
  max-width: 100%;
  max-height: 96dvh;
  border: 1px solid rgba(255, 238, 210, 0.42);
  border-radius: 10px;
  background: #e8e8e8;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
  touch-action: manipulation;
}

.side-panel {
  align-self: center;
  width: var(--panel-width);
  padding: 22px;
  border: 1px solid rgba(255, 238, 210, 0.12);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(48, 34, 23, 0.96), rgba(29, 21, 14, 0.96));
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.26);
}

h1 {
  margin: 0 0 22px;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: var(--text);
}

.control-stack {
  display: grid;
  gap: 14px;
}

.field,
.check-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.check-field {
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

select,
button {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 238, 210, 0.18);
  border-radius: 11px;
  background: var(--panel-soft);
  color: var(--text);
  outline: none;
}

select {
  padding: 0 12px;
}

button {
  cursor: pointer;
  background: linear-gradient(180deg, #4a321f, #2f2118);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover:not(:disabled),
button:focus-visible:not(:disabled) {
  border-color: rgba(215, 168, 91, 0.86);
  background: linear-gradient(180deg, #5a3d25, #382719);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status {
  min-height: 46px;
  margin: 4px 0 0;
  padding: 12px;
  border-radius: 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.16);
  line-height: 1.35;
}

@media (max-width: 899px) {
  html,
  body {
    overflow-x: hidden;
  }

  .app-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 0;
    padding: 0;
  }

  .board-section {
    width: 100vw;
    height: 100vw;
    flex: 0 0 100vw;
  }

  #board {
    width: 100vw;
    height: 100vw;
    max-width: 100vw;
    max-height: 100vw;
    border-radius: 0;
    box-shadow: none;
  }

  .side-panel {
    width: 100%;
    align-self: stretch;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 16px max(14px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    background: rgba(36, 26, 18, 0.98);
  }

  h1 {
    margin-bottom: 14px;
    font-size: 26px;
  }

  .control-stack {
    gap: 11px;
  }
}
