/* ===============================
   BASE
================================ */
:root{
  --bg:#07080b;
  --fg:#e9eef7;
  --muted:#9aa6b6;
  --bg-image: url("../assets/images/cabane_bg.png");
  --panel:rgba(12,14,18,.72);
  --line:rgba(255,255,255,.10);
  --accent:#c7ff6b;
  --danger:#ff5a6a;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

*{
  box-sizing:border-box;
}

html,body{
  width:100%;
  height:100%;
  margin:0;
  padding:0;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--bg);
  color:var(--fg);
  font-family:var(--font);
  overflow:hidden;
}

/* ===============================
   APP STRUCTURE
================================ */
.app{
  position:relative;
  width:100vw;
  height:100vh;
}

/* ===============================
   BACKGROUND FX
================================ */
.bg{
  position:absolute;
  inset:0;
  background:
    var(--bg-image) center/cover no-repeat,
    radial-gradient(1200px 800px at 50% 40%, rgba(70,90,130,.10), transparent 55%),
    linear-gradient(#06070a,#07080b);
}

.grain{
  position:absolute;
  inset:-20%;
  opacity:.12;
  background-size:320px 320px;
  mix-blend-mode:overlay;
  pointer-events:none;
}

.vignette{
  position:absolute;
  inset:0;
  background:radial-gradient(60% 50% at 50% 40%, transparent 55%, rgba(0,0,0,.65));
  pointer-events:none;
}

.scanlines{
  position:absolute;
  inset:0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,.03),
    rgba(255,255,255,.03) 1px,
    transparent 2px,
    transparent 6px
  );
  opacity:.18;
  pointer-events:none;
}

.start-fade{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.9);
  opacity:0;
  pointer-events:none;
  z-index:12;
}

.start-fade--active{
  opacity:1;
}

.start-fade--open{
  opacity:0;
}

.start-fade--beat{
  animation: start-eyes-open var(--start-beat, 4.8s) ease-out forwards;
}

.intro-video{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  opacity:0;
  pointer-events:none;
  z-index:13;
  background:#000;
}

.intro-video--active{
  opacity:1;
  pointer-events:auto;
}

@keyframes start-eyes-open{
  0%   { opacity:0.97; }
  12%  { opacity:0.86; }
  26%  { opacity:0.92; }
  42%  { opacity:0.78; }
  58%  { opacity:0.86; }
  76%  { opacity:0.65; }
  100% { opacity:0; }
}

/* ===============================
   SCREENS
================================ */
.screen{
  position:absolute;
  inset:0;
  display:none;
}

.screen--active{
  display:flex;
}

/* ===============================
   MENU
================================ */
#menu{
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:28px;
  padding:32px;
  z-index:5;
}

.menu-main{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:28px;
  width:100%;
}

.titleblock{
  text-align:center;
}

.title{
  font-size:56px;
  letter-spacing:.08em;
  margin:0;
}

.subtitle{
  color:var(--muted);
  margin-top:8px;
}

.panel{
  width:min(520px, 92vw);
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:18px;
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:10px;
  backdrop-filter:blur(10px);
}

.panel--chronos{
  width:min(720px, 92vw);
  max-height:78vh;
  overflow:auto;
}

.panel__header{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  margin-bottom:6px;
}

.panel__sub{
  margin:0;
  font-size:12px;
  color:var(--muted);
}

.btn{
  padding:14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:var(--fg);
  font-size:16px;
  cursor:pointer;
}

.btn:hover{
  background:rgba(255,255,255,.08);
}

.btn--primary{
  background:rgba(199,255,107,.12);
  border-color:rgba(199,255,107,.35);
}

.btn--danger{
  background:rgba(255,90,106,.12);
  border-color:rgba(255,90,106,.35);
}

.tiny{
  text-align:center;
  font-size:12px;
  color:var(--muted);
  margin-top:8px;
}

.menu-scores{
  margin-top:10px;
  padding-top:12px;
  border-top:1px solid var(--line);
}

.menu-scores__title{
  font-size:11px;
  letter-spacing:.10em;
  text-transform:uppercase;
  color:var(--muted);
  margin-bottom:6px;
}

.menu-scores__table{
  font-size:12px;
  margin:0 0 6px;
}

.menu-scores__table th,
.menu-scores__table td{
  padding:4px 6px;
}

.menu-scores__empty{
  font-size:12px;
  color:var(--muted);
}

/* ===============================
   GAME SCREEN
================================ */
#game{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100vw;
  height:100vh;
  z-index:4;
}

/* === CANVAS: FULL SCREEN === */
#canvas{
  display:block;
  width:100vw;
  height:100vh;
  background: transparent;
  image-rendering:auto;
}

/* ===============================
   HUD
================================ */
.hud{
  position:absolute;
  bottom:16px;
  left:16px;
  /* keep compact on the left */
  display:flex;
  flex-direction:column;
  gap:8px;
  pointer-events:none;
  z-index:10;
  max-width:360px;
}

.hud__row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.hud__pill{
  background:rgba(0,0,0,.40);
  border:1px solid rgba(255,255,255,.10);
  border-radius:999px;
  padding:6px 10px;
  font-size:11px;
}

.hud__bar{
  flex:1;
  min-width:150px;
  background:rgba(0,0,0,.35);
  border:1px solid rgba(255,255,255,.10);
  border-radius:14px;
  padding:10px;
}

.hud__label{
  font-size:11px;
  color:var(--muted);
  margin-bottom:6px;
}

.hud__meter{
  height:8px;
  background:rgba(255,255,255,.08);
  border-radius:999px;
  overflow:hidden;
}

.hud__fill{
  height:100%;
  width:50%;
  background:rgba(199,255,107,.60);
}

.hud__small{
  font-size:10px;
  background:rgba(0,0,0,.30);
  border:1px solid rgba(255,255,255,.10);
  border-radius:10px;
  padding:6px 8px;
}

/* ===============================
  OVERLAYS (OPTIONS / CREDITS)
================================ */
.overlay{
  position:absolute;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.55);
  z-index:20;
}

.overlay--active{
  display:flex;
}

.overlay__card{
  width:min(720px, 94vw);
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:18px;
  padding:18px;
  backdrop-filter:blur(12px);
}

.actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:12px;
}

.endgrid{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:16px;
  margin:8px 0 12px;
}

.endresult{
  font-size:20px;
  font-weight:700;
  letter-spacing:.04em;
}

.endtime{
  font-size:14px;
  color:var(--muted);
}

.endtable{
  width:100%;
  border-collapse:collapse;
  margin:6px 0 12px;
  font-size:14px;
}

.endtable th,
.endtable td{
  text-align:left;
  padding:6px 8px;
  border-bottom:1px solid rgba(255,255,255,.08);
}

.endtable th{
  color:var(--muted);
  font-weight:600;
}

.overlay__header{
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.iconbtn{
  width:36px;
  height:36px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:var(--fg);
  cursor:pointer;
}

/* remove browser focus outlines for buttons and canvas (we handle focus visually in-canvas) */
.btn:focus,
.iconbtn:focus,
#canvas:focus,
button:focus {
  outline: none;
  box-shadow: none;
}

/* remove tap highlight on mobile */
button, a, #canvas { -webkit-tap-highlight-color: transparent; }
