
 *{
  box-sizing: border-box;
}

.tile {
  width: 50px;
  height: 55px;
  border: 2px solid #555;
  font-size: 28px;
  font-weight: bold;
  line-height: 55px;
  text-transform: uppercase;
  text-align: center;
  border-radius: 1px;
}

body {
  font-family: "Arial", sans-serif; 
  background-color: #221E22; 
  color: #ddd;
  text-align: center;
}

#grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 0px;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: fit-content;
  z-index: 10;
}

.row {
  display: flex;
  justify-content: center;
  gap: 4px;
  position: relative;
  white-space: nowrap;
}

.score {
  position: absolute;
  right: -110px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 80px;
  font-weight: bold;
  color: #fff;
  text-align: left;
  font-size: 20px;
}

@keyframes shake {
  0%   { border-color: #787c7e; }
  25%  { border-color: #ff4444; }
  50%  { border-color: #ff4444; }
  75%  { border-color: #787c7e; }
  100% { border-color: #787c7e; }
}

.row.shake {
  animation: shake 0.4s;
}

#game {
  position: relative;
  width: max-content;
  margin: 0 auto;
}

#message {
  position: absolute;
  top:50px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: #222;
  color: #fff;
  font-weight: bold;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 9999;
}

#message.show {
  opacity: 1;
}

@keyframes winPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.15); }
  60%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.tile.win {
  animation: winPop 0.4s ease forwards;
}

.tile {
  perspective: 600px;
}

.tile.flip {
  animation: flip 0.6s ease forwards;
}

@keyframes flip {
  0% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(90deg);
    background: #221E22;
  }
  100% {
    transform: rotateX(0deg);
  }
}

.keyboard {
    margin-top: 0px;
    user-select: none;
}

.key-row {
    margin-bottom: 5px;
}

.key {
    border: 0px solid #555;
    border-radius: 4px;
    background-color: #AEAEAE;
    transition: background 0.5s ease, color 0.5s ease;
}

.key:active {
    background-color: #555;
}

#banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;

  background: #121213;
  color: white;

  padding: 12px 12px;

  display: flex;
  justify-content: flex-start;
  align-items: center;

  font-family: 'Arial', sans-serif;
  box-shadow: 0 10px 15px rgba(0,0,0,0.3);
  z-index: 1000;
}

#banner h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 2px;
}

#banner span {
  margin-left: auto;
  font-size: 1rem;
}

.help-btn {
  background: none;
  border: 2px solid #ddd;
  color: #ddd;
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.help-btn:hover {
  background: #ddd;
  color: #121213;
  border-color: #ddd;
}

.stats-btn {
  background: none;
  border: 2px solid #ddd;
  color: #ddd;
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: absolute;
  right: 60px;
  top: 50%;
  transform: translateY(-50%);
}

.stats-btn:hover {
  background: #ddd;
  color: #121213;
  border-color: #ddd;
}

#grid-container {
  padding-top: 70px; 
}

#main-content {
  padding-top: 60px;
}

@keyframes bounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.3); }
  50%  { transform: scale(0.9); }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.tile.bounce {
  animation: bounce 0.4s ease;
}

.grid.shake {
  animation: gridShake 0.6s;
}

@keyframes gridShake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-10px); }
  80% { transform: translateX(10px); }
  100% { transform: translateX(0); }
}

.loss-banner {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-weight: bold;
  opacity: 0;
  animation: fadeIn 0.5s forwards;
  z-index: 1000;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.loss-banner {
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.25);
}

@media (max-width: 480px) {
  .tile {
    width: 48px;
    height: 48px;
    font-size: 26px;
  }

  #game {
    padding: 12px;
  }
}

#game {
  max-width: 420px;
  margin: 0 auto;
  padding: 16px;
}

html, body {
  width: 100%;
  overflow-x: hidden;
}

@media (max-width: 480px) {
  .tile {
    width: 50px;
    height: 55px;
    line-height: 55px;
    font-size: 26px;
  }

  .top-banner {
    font-size: 16px;
  }
}
#banner > * {
  max-width: 420px;
  margin: 0 auto;
}

.keyboard-wrapper {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  padding: 10px;
  box-sizing: border-box;
  z-index: 1000;
}

.keyboard {
  width: 100%;
  background-color: #221E22;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.key {
  height: 58px;
  padding: 0 10px;
  min-width: 32px;
  border: none;
  border-radius: 4px;
  background-color: #AEAEAE;
  color: #fff;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.3s ease;
}

.key.wide {
  padding: 0 25px;
  font-size: 0.7rem;
}

.key:active {
  background-color: #555;
}

@media (max-width: 480px) {
  .keyboard-wrapper {
    transform: translateX(-50%) scale(0.85);
    transform-origin: bottom center;
  }

  .key {
    height: 64px;
    font-size: 0.95rem;
  }
}

.end-popup.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.end-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.4s ease-in;
}
.end-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}
.end-popup-content {
  position: relative;
  background: #121213;
  color: #fff;
  padding: 0;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.6);
  min-width: 280px;
  max-width: 90%;
  z-index: 2001;
}

.end-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #333;
}

.end-popup-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.popup-close-btn {
  background: none;
  border: none;
  color: #ddd;
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.popup-close-btn:hover {
  color: #fff;
}

.end-popup-content p {
  margin: 0;
  padding: 20px 20px 0 20px;
}
.end-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.end-actions button {
  background: #6aaa64;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}

.share-area {
  padding: 20px;
  text-align: center;
}
.share-area.hidden {
  display: none;
}
.share-header {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 6px;
}
.share-link {
  font-size: 13px;
  color: #9fb4d9;
  margin-bottom: 8px;
}
.share-output {
  background: #0f1720;
  color: #fff;
  padding: 10px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.2;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow: auto;
}
.share-controls {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
}

.help-popup.hidden {
  display: none;
}

.help-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  animation: fadeIn 0.4s ease-in;
}

.help-popup-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
}

.help-popup-content {
  position: relative;
  background: #121213;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.help-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #333;
}

.help-popup-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.help-close-btn {
  background: none;
  border: none;
  color: #ddd;
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.help-close-btn:hover {
  color: #fff;
}

.help-popup-body {
  padding: 20px;
  line-height: 1.6;
}

.help-popup-body p {
  margin: 12px 0;
}

.help-popup-body ul {
  margin: 12px 0;
  padding-left: 20px;
}

.help-popup-body li {
  margin: 8px 0;
}

.share-controls button {
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: #2d7bf6;
  color: #fff;
  font-weight: bold;
}

.share-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.share-controls button {
  background: #333;
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
}

.share-controls #closeShareBtn {
  background: #444;
}

.end-popup-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px 20px;
  margin-top: 0px;
}

.countdown-container {
  padding: 0px 0px;
  text-align: center;
  color: #aaa;
  font-size: 0.9rem;
}
.countdown-container.hidden {
  display: none;
}
.countdown-container p {
  margin: 0;
}

.countdown-container span {
  font-weight: bold;
  color: #ddd;
  font-family: monospace;
}

.unlimited-btn {
  background: #6aaa64;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 1rem;
}

.unlimited-btn:hover {
  background: #5a9a54;
}

@media (max-width: 480px) {
  .help-popup {
    transform: translateX(-00%) scale(0.85);
    transform-origin: top center;
  }
  .help-popup-backdrop {
    transform: translateX(-00%) scale(1.3);
    transform-origin: top center;
  }
  .stats-popup {
    transform: translateX(-00%) scale(0.85);
    transform-origin: top center;
  }
  .stats-popup-backdrop {
    transform: translateX(-00%) scale(1.3);
    transform-origin: top center;
  }
  }

.stats-popup.hidden {
  display: none;
}

.stats-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  animation: fadeIn 0.4s ease-in;
}

.stats-popup-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
}

.stats-popup-content {
  position: relative;
  background: #121213;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.stats-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #333;
}

.stats-popup-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.stats-popup-body {
  padding: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat {
  text-align: center;
  padding: 10px;
  background: #1a1a1b;
  border-radius: 6px;
}

.stat-number {
  font-size: 1.8rem;
  font-weight: bold;
  color: #EE5622;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.85rem;
  color: #999;
}




