:root { --gap: 8px; --cell: 52px; --radius: 10px; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: #fafafa; }

.top {
  display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid rgba(0,0,0,.08); background: #fff;
}
.brand { min-width: 0; }
h1 { margin: 0; font-size: 20px; }
.sub { font-size: 13px; opacity: .75; margin-top: 2px; }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.controls label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
select, button { font-size: 14px; padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(0,0,0,.18); background: #fff; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }

.wrap {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.boardPanel { min-width: 0; }
.status { margin-bottom: 10px; font-size: 14px; opacity: .85; }

.board {
  display: inline-grid;
  /* This is the magic line: it uses the --grid-size variable from JS */
  grid-template-columns: repeat(var(--grid-size, 5), 1fr);
  
  /* Your original 'fit-content' logic */
  width: fit-content;
  max-width: 100%;
  align-self: flex-start;

  /* Your original styling logic */
  background-color: #f4f6f8;
  border: 1px solid #c8ced6;
  border-radius: 6px;
  padding: 8px;
  box-sizing: border-box;
  
  /* Recommended: adds a consistent gap between tiles */
  gap: 8px; 
}

.cell {
  width: var(--cell);
  height: var(--cell);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  border: 1px solid rgba(0,0,0,.12);
}

.cell.empty {
  background: #e3e6ea;
  border: 1px solid #d0d5db;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}



.cell.dragging-from {
  outline: 3px solid rgba(255, 170, 0, .7);
  transform: scale(1.03);
}

.cell.letter {
  background: #ffffff;
  border: 1px solid #cfd4da;
}

.cell.letter.selected { outline: 3px solid rgba(0,0,0,.35); }
.cell.scoring { box-shadow: 0 0 0 3px rgba(0, 160, 0, .25) inset; }

.hint { margin-top: 10px; font-size: 13px; opacity: .75; }

.side { display: grid; gap: 12px; align-content: start; }
.card { border: 1px solid rgba(0,0,0,.10); border-radius: 14px; padding: 12px; background: #fff; }
.cardTitle { font-weight: 700; margin-bottom: 10px; }

.scoreRow { display: flex; gap: 14px; align-items: center; }
.scoreBig { font-size: 44px; font-weight: 900; line-height: 1; }
.scoreMeta { font-size: 13px; opacity: .85; display: grid; gap: 4px; }
.k { opacity: .65; margin-right: 8px; }

.wordsList { font-size: 13px; line-height: 1.45; max-height: 45vh; overflow: auto; }
.wordsList .w { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px dashed rgba(0,0,0,.10); }
.wordsList .w:last-child { border-bottom: none; }
.wordsList .pts { opacity: .7; }

.rules { margin: 0; padding-left: 18px; font-size: 13px; opacity: .85; display: grid; gap: 6px; }

@media (max-width: 920px) {
  .wrap { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  :root { --cell: 44px; --gap: 7px; }
}
.cell.dropok {
  outline: 3px solid rgba(0, 120, 255, .45);
}
.board { touch-action: none; }
.cell  { touch-action: none; }
.cell.dropok { outline: 3px solid rgba(0, 120, 255, .45); }
/* Header layout */
header.top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

/* Brand block */
header.top .brand {
  align-items: flex-start;   /* 👈 left-align children (logo, h1, sub) */
  text-align: left;
}




/* Make sure logo doesn't blow out width */
.wordslide-mark {
  display: block;
  height: 52px;             /* tweak */
  width: auto;
  max-width: 100%;
}

/* added to make h1 slide right */
.brand.top {
  display: flex;
  flex-direction: row;      /* Force side-by-side */
  justify-content: flex-start; /* Ensure they stay on the left (or start) */
  align-items: center;      /* Vertical center */
  gap: 10px;                /* This is the EXACT space between them */
  width: fit-content;       /* Prevents the container from stretching full-width */
}

.brand.top h1 {
  margin: 0;                /* Removes the default h1 push */
  display: inline-block;    /* Ensures it doesn't behave like a full-width block */
  line-height: 1;           /* Better vertical alignment with the image */
}

.wordslide-mark {
  height: 40px;          /* Adjust this to match the height of your text */
  width: auto;
}


/* Controls */
header.top .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* iPhone / narrow screens: controls go BELOW brand, and center/stack nicely */
@media (max-width: 520px) {
  header.top {
    flex-direction: column;   /* brand on top, controls below */
    align-items: stretch;
  }

  header.top .controls {
    width: 100%;
  }
}
/* Feedback for the new 'Buffered' rules */
.cell.valid {
    background-color: #d4edda; /* Green tint */
    border: 2px solid #28a745;
    color: #155724;
}

.cell.invalid {
    background-color: #f8d7da; /* Red tint */
    border: 2px solid #dc3545;
    color: #721c24;
}

/* Optional: Pulse animation for a completed word */
@keyframes word-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
.cell.valid-anim {
    animation: word-pop 0.3s ease-out;
}
#win-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: celebrate 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hidden { display: none !important; }

.animate-win {
    display: inline-block;
    animation: word-pop 0.6s ease-in-out infinite;
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.win-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); /* Darker for drama */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.win-card {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    transform: scale(0.7);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    max-width: 400px;
    width: 90%;
}

@keyframes popIn {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.win-icon { font-size: 4rem; margin-bottom: 1rem; }
.win-btn {
    margin-top: 20px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
}
.win-btn:hover { transform: scale(1.05); }
.hidden { display: none !important; }
#win-stats {
    margin: 15px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    font-family: monospace;
    font-size: 1.1rem;
    color: #333;
}
#reveal-toggle-btn {
    transition: background-color 0.3s ease, color #007AFF ease;
    color: #007AFF; 
    /* your other button styles */
}
/* Target all buttons to ensure consistency across iPad/Desktop */
button {
  /* This is the standard "iOS Blue" */
  color: #007AFF; 
  background-color: white;
  border: 1px solid #c8ced6;
  border-radius: 6px;
  padding: 8px 16px;
  font-weight: 500;
  cursor: pointer;
  
  /* Removes the iPad's default rounded grey styling */
  -webkit-appearance: none; 
}

button:active {
  background-color: #f0f0f0;
}
/* Ensure the Reveal button specifically stays black when in its white state */
