/* ==== Global Colors / Base ==== */
:root {
  --bg: #121213;
  --panel: #1a1a1b;
  --text: #d7dadc;
  --tile-border: #3a3a3c;
  --green: #538d4e;
  --green-dim: #1d3b2a;
  --key: #3a3a3c;
}

* { box-sizing: border-box; }

/* Reset + background fix */
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  text-align: center;
  padding: 0 16px 16px 16px;
  position: relative;
}

/* Safari fix: fill top safe area with background */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top);
  background: var(--bg);
  z-index: 9999;
}


.wrap { max-width: 520px; margin: 0 auto; background: transparent; }

h1 { font-size: 22px; margin: 0 0 8px; }

.msg {
  min-height: 20px;
  margin-top: 8px;
  font-size: 14px;
  font-weight: 500;
}

/* ==== Mini instructions ==== */
.mini-instructions p {
  margin: 2px 0;
  line-height: 1.2;
  font-size: 14px;
}
.mini-instructions {
  margin-bottom: 10px; /* gap before How to Play button */
}

/* ==== Icon font (IcoMoon export) ==== */
[class^="icon-"], [class*=" icon-"] {
  font-family: 'icomoon' !important;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-tile_square,
.icon-tile_blank,
.icon-tile_left,
.icon-tile_right {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  vertical-align: middle;
  margin: 0 4px;
}

.icon-tile_square {
  font-size: 1em;
  position: relative;
  top: -0.05em;
}

.icon-tile_left,
.icon-tile_right {
  font-size: 1.2em;
  position: relative;
  top: -0.02em;
}

/* ==== Help button ==== */
.help-btn {
  background: var(--key);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.2s;
}
.help-btn:hover { background: var(--green); }

#streak-counter-box {
  margin: 10px;
  font-size: 14px; /* was 18px */
  font-weight: bold;
  color: #d7dadc;
}

#streak-counter {
  color: #538d4e;
}

#longest-streak {
  color: #aaa;
}

#streak-saver {
  display: none;
  margin-top: 6px;
  padding: 4px 10px;
  font-size: 14px;
  background: #538d4e;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.streak-wrap {
  display: flex;
  justify-content: center; /* center them horizontally */
  gap: 12px;               /* space between */
}

.streak-wrap p {
  margin: 0;
}


/* ==== Game Board ==== */
.board {
  display: grid;
  grid-template-rows: repeat(6, minmax(6vh, 48px)); /* scale by screen height */
  gap: clamp(2px, 0.8vh, 5px);
  margin-top: 8px;
  justify-content: center;
}

.row {
  display: grid;
  grid-template-columns: repeat(5, minmax(6vh, 48px));
  gap: clamp(2px, 0.8vh, 5px);
}

/* ---- Tile + Flip animation ---- */
.tile {
  perspective: 1000px;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden; /* keeps 3D layers clean */
}

.tile-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
  will-change: transform;
}

.tile.flipped .tile-inner {
  transform: rotateY(180deg);
}

/* faces */
.tile-front,
.tile-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;

  font-size: clamp(16px, 4vw, 22px);
  font-weight: 800;
  color: #fff;

  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  transform: translateZ(0);
}

/* front = neutral blank grid */
.tile-front {
  background-image: url("./tile_blank.svg");
}

/* back rotates into view */
.tile-back {
  transform: rotateY(180deg) translateZ(0);
}

/* back backgrounds (your SVGs) */
.tile-back.tile-left   { background-image: url("./tile_left.svg"); }
.tile-back.tile-right  { background-image: url("./tile_right.svg"); }
.tile-back.tile-square { background-image: url("./tile_square.svg"); }
.tile-back.tile-blank  { background-image: url("./tile_blank.svg"); }

/* ==== Keyboard ==== */
.keyboard {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: clamp(3px, 0.8vh, 6px);
}

.key-row {
  display: flex;
  justify-content: center;
  gap: clamp(3px, 0.8vh, 6px);
}

.key {
  background: var(--key);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, transform 0.02s;

  width: clamp(34px, 8vw, 44px);
  height: clamp(48px, 10vw, 56px);
  font-size: clamp(16px, 3.5vw, 18px);
  padding: 0;
  text-align: center;

  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.key.wide {
  width: clamp(52px, 12vw, 72px);
  font-size: clamp(16px, 3.2vw, 16px);
}

.key.correct { background: var(--green); }
.key.wrong { background: var(--tile-border); }



/* ==== Modal (How to Play) ==== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  background-color: rgba(0,0,0,0.8);
}
.modal-content {
  background: var(--panel);
  margin: 10% auto;
  padding: 20px;
  border: 2px solid var(--tile-border);
  border-radius: 8px;
  width: 90%;
  max-width: 520px;
  color: var(--text);
  text-align: left;
  font-size: 14px;
}
.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: 800;
  cursor: pointer;
}
.close:hover { color: #fff; }

/* ==== Very Small Screens ==== */
@media (max-width: 400px) {
  h1 { font-size: 18px; }
  .msg { font-size: 12px; }
  .mini-instructions { font-size: 12px; }
}

/* ==== Flip keyframes (for smooth tile rotation) ==== */
@keyframes flip {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg); background-image: none; }
  100% { transform: rotateY(0deg); }
}

/* share button */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 10px;
  border: 0;
  font-weight: 600;
  cursor: pointer;
}
.btn-green { background: #3aa65a; color: #fff; }

/* hide share box until game ends */
#shareBox {
  display: none;
  margin-top: 12px;
}


/* hide the textarea but keep it usable for programmatic copy */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}


