:root{
  --bg: #0b0d10;
  --card: rgba(255,255,255,0.05);
  --card2: rgba(0,0,0,0.20);
  --text: #e8edf5;
  --muted: #a9b3c1;
  --border: rgba(255,255,255,0.12);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --radius: 14px;
  --gap: 16px;
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
  margin: 0;
  overflow: hidden; /* prevent page-level scrolling */
}

body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 17px;
  background:
    radial-gradient(1200px 600px at 20% 0%, rgba(60,80,255,0.15), transparent 60%),
    radial-gradient(1000px 500px at 100% 20%, rgba(0,200,255,0.12), transparent 60%),
    var(--bg);
  color: var(--text);
}

/* =========================================================
   Page layout: header + centered content, no overflow
========================================================= */
.page{
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px;

  height: 100vh;
  max-height: 100vh;
  overflow: hidden;

  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
}

.header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gap);

  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);

  max-width: min(980px, 96vw);
  margin: 0 auto;
}

.title{
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.subtitle{
  margin: 6px 0 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  max-width: 720px;
}

.meta{
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}
.meta span{
  color: var(--text);
  font-weight: 650;
}

/* Status pill (keep compact; center text properly) */
.pill{
  align-self: center;
  display: flex;
  align-items: center;       /* vertical centering */
  justify-content: center;

  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 13px;

  max-width: 460px;
  min-height: 40px;
  max-height: 56px;
}

/* =========================================================
   Single-column centered layout (no side panel)
   Key fix: the whole content area fits within remaining height,
   and the stimulus area shrinks to leave room for contact text.
========================================================= */
.layout.single{
  flex: 1;                   /* take remaining height below header */
  min-height: 0;             /* critical: allow children to shrink */
  width: 100%;

  display: flex;
  justify-content: center;
  align-items: stretch;

  max-width: min(980px, 96vw);
  margin: 0 auto;
}

/* Hide side panel if it exists */
.panel{ display: none !important; }

/* Main card: fixed within layout.single height */
.stimulus-card{
  width: 100%;

  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;

  display: flex;
  flex-direction: column;
  gap: 10px;

  min-height: 0;             /* critical */
  max-height: 100%;          /* do not exceed layout.single height */
  overflow: hidden;          /* prevent internal overflow affecting page */
}

/* Hint and contact should not grow; keep them compact */
.hint{
  font-size: 14px;
  line-height: 1.35;
  opacity: 0.85;
  text-align: center;
  flex: 0 0 auto;
  margin: 0;
}

.contact{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  flex: 0 0 auto;
  margin: 0;
}

/* The stimulus region takes remaining space ONLY (so contact stays visible) */
.stimulus{
  flex: 1 1 auto;            /* grow + shrink */
  min-height: 0;             /* critical: allow shrink so contact remains visible */
  overflow: hidden;

  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0,0,0,0.35);

  display: flex;
  align-items: center;
  justify-content: center;
}

/* Image scales to fit inside the stimulus box */
.stimulus img,
#stimulus{
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  cursor: crosshair;
}

/* Keyboard key styling */
kbd{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.hidden{ display: none !important; }

/* =========================================================
   Responsive tweaks
========================================================= */
@media (max-width: 900px){
  .page{ padding: 14px; }
  .header{ max-width: 96vw; }
  .layout.single{ max-width: 96vw; }
  .pill{ max-width: none; }
}

/* =========================================================
   Instruction Overlay
========================================================= */
.overlay{
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-card{
  background: #111;
  color: #f2f2f2;

  width: min(700px, 92vw);
  padding: 28px 32px;
  border-radius: 14px;

  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  text-align: left;
}

.overlay-card h2{
  margin: 0 0 14px 0;
  font-size: 22px;
  font-weight: 600;
}

.overlay-card p{
  margin: 10px 0;
  font-size: 15px;
  line-height: 1.45;
}

.overlay-card ul{
  margin: 6px 0 12px 18px;
  padding: 0;
}

.overlay-card li{
  margin: 6px 0;
  font-size: 15px;
}

.overlay-card .note{
  font-size: 14px;
  opacity: 0.85;
  margin-top: 10px;
}

.primary-btn{
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 12px 0;

  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 10px;

  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn:hover{
  background: #2563eb;
}
