:root {
  --bg: #f5efe2;
  --panel: rgba(255, 250, 240, 0.92);
  --panel-strong: rgba(255, 248, 232, 0.98);
  --line: rgba(71, 52, 23, 0.14);
  --text: #24180d;
  --subtle: #6f5a45;
  --accent: #b14d25;
  --accent-strong: #8f3512;
  --board-gap: 0;
  --shadow: 0 18px 44px rgba(61, 39, 14, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Hiragino Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(245, 174, 85, 0.22), transparent 30%),
    radial-gradient(circle at bottom right, rgba(177, 77, 37, 0.18), transparent 24%),
    linear-gradient(135deg, #f8f2e8 0%, #ead8b9 100%);
  min-height: 100vh;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px;
}

body.focus-mode {
  overflow: hidden;
}

body.focus-mode .hero,
body.focus-mode .controls-panel {
  display: none;
}

body.focus-mode .app-shell {
  max-width: none;
  min-height: 100vh;
  padding: 16px;
  display: grid;
  place-items: center;
}

body.focus-mode .main-layout {
  display: block;
  width: min(96vmin, 1120px);
}

body.focus-mode .board-panel {
  padding: 16px;
}

body.focus-mode .board-meta {
  display: none;
}

body.focus-mode .board {
  width: 100%;
  max-width: none;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.3rem, 5vw, 4.6rem);
  line-height: 0.95;
}

.lead {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--subtle);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#videoFiles {
  display: none;
}

.button {
  border: 1px solid rgba(71, 52, 23, 0.16);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 0.92rem 1.2rem;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease;
  box-shadow: var(--shadow);
}

.button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  position: fixed;
  right: 14px;
  bottom: 12px;
  z-index: 20;
  border: 0;
  background: rgba(36, 24, 13, 0.14);
  color: rgba(36, 24, 13, 0.72);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, background-color 180ms ease;
}

.ghost-button:hover {
  background: rgba(36, 24, 13, 0.22);
}

body.focus-mode .ghost-button {
  opacity: 1;
  pointer-events: auto;
}

.main-layout {
  display: block;
}

.board-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.board-panel {
  padding: 22px;
}

.board-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.board-meta h2,
.panel-card h2 {
  margin-bottom: 8px;
}

#statusText {
  color: var(--subtle);
  margin-bottom: 0;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--subtle);
  font-size: 0.92rem;
  text-align: right;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--board-gap);
  aspect-ratio: 1 / 1;
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 0;
  border-radius: 24px;
  background: rgba(88, 60, 24, 0.12);
}

.tile,
.empty-slot {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0;
}

.tile {
  border: 1px solid rgba(71, 52, 23, 0.12);
  overflow: hidden;
  padding: 0;
  background: rgba(255, 249, 240, 0.9);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  box-shadow: 0 12px 30px rgba(56, 39, 19, 0.14);
}

.tile:hover {
  transform: translateY(-2px);
  border-color: rgba(177, 77, 37, 0.4);
}

.tile.is-muted {
  border-color: rgba(92, 92, 92, 0.48);
  background: rgba(190, 190, 190, 0.96);
  box-shadow: 0 8px 18px rgba(56, 39, 19, 0.05);
}

.tile-frame {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
}

.video-shell {
  width: 100%;
  height: 100%;
  position: relative;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(238, 225, 205, 0.65)),
    repeating-linear-gradient(
      45deg,
      rgba(177, 77, 37, 0.08),
      rgba(177, 77, 37, 0.08) 12px,
      transparent 12px,
      transparent 24px
    );
  border-radius: 0;
  overflow: hidden;
}

.video-matte {
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
}

.video-shell.has-black-matte .video-matte {
  background: #000;
}

.video-shell.has-black-matte {
  background: #000;
}

.video-shell video {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: #120b06;
}

.tile-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: rgba(22, 14, 6, 0.76);
  color: #fff8ef;
  font-size: 0.85rem;
  font-weight: 700;
}

body.hide-labels .tile-label {
  display: none;
}

.empty-slot {
  border: 2px dashed rgba(71, 52, 23, 0.16);
  background: rgba(119, 90, 49, 0.08);
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .hero {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .board-meta {
    flex-direction: column;
  }

  .legend {
    text-align: left;
  }
}
