body {
  margin: 0;

  font-family: Tahoma, "Noto Sans Tamil", sans-serif;

  background: #fafafa;

  text-align: center;

  padding-bottom: 280px;

  /* space for keyboard */
}

header {
  text-align: center;

  padding: 20px 10px 6px;

  border: 2px solid #ddd;

  border-radius: 8px;

  margin: 10px;

  background: #fff;

  color: black;
}

header h1 {
  margin: 0;

  font-size: 36px;

  letter-spacing: 2px;
}

header p {
  margin: 4px 0 11px;

  color: #555;
}

/* Modal Styles */

/* Backdrop */

.modal-backdrop {
  position: fixed;

  inset: 0;

  background: rgba(0, 0, 0, 0.45);

  display: flex;

  align-items: center;

  justify-content: center;

  z-index: 1000;
}

.modal-backdrop.hidden {
  display: none;
}

/* Modal box */

.modal {
  background: #fff;

  width: 90%;

  max-width: 420px;

  border-radius: 16px;

  text-align: left;

  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);

  overflow: hidden;

  font-family: Tahoma, "Noto Sans Tamil", sans-serif;
}

/* Header */

.modal-header {
  display: flex;

  justify-content: space-between;

  align-items: left;

  padding: 16px 20px;

  border-bottom: 1px solid #eee;
}

.modal-header h2 {
  margin: 8px 2px;

  font-size: 20px;
}

.close-btn {
  background: none;

  border: none;

  padding: 0px 14px;

  font-size: 26px;

  cursor: pointer;

  color: #666;
}

.header3 {
  margin-left:90px;
  font-size: 1.17em;
  font-weight: bold;
}

.stats-btn {
  margin-left: 10px;
  display: flex;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  margin-right: 8px;
  cursor: pointer;
}
.stats-btn .game-icon {
  width: 28px;
  height: 24px;
  vertical-align: middle;
}

#statsModal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

#statsModal .modal-content {
  padding: 16px 20px;
  font-size: 15px;
  line-height: 1.5;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}
.stats-item {
  text-align: center;
  flex: 1;
}
.stats-item strong {
  font-size: 22px;
  display: block;
}
.stats-barchart {
  margin-top: 18px;
}
.stats-barchart .bar {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}
.stats-barchart .bar-label {
  width: 24px;
  text-align: right;
  margin-right: 8px;
  font-size: 15px;
}
.stats-barchart .bar-value {
  background: #888;
  height: 18px;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  padding: 0 8px;
  min-width: 32px;
  display: flex;
  align-items: center;
}

/* Content */

.modal-content {
  padding: 12px 20px;

  font-size: 15px;

  line-height: 1.5;
}

.mission-statement {
  margin-block-start: 0;
}

.rules {
  padding-left: 18px;

  margin: 0 0 16px;
}

.rules li {
  margin-bottom: 8px;
}

/* Legend */

.legend {
  display: flex;

  gap: 16px;

  margin-bottom: 16px;

  font-size: 14px;
}

.legend div {
  display: flex;

  align-items: center;

  gap: 6px;
}

.tile {
  width: 18px;

  height: 18px;

  border-radius: 4px;

  display: inline-block;
}

.tile.green {
  background: #4caf50;
}

.tile.red {
  background: #f44336;
}

/* Example */

.example {
  background: #f7f7f7;

  border-radius: 12px;

  padding: 12px;
}

.example h3 {
  margin: 0 0 6px;

  font-size: 16px;
}

.rules-row {
  display: flex;
  align-items: center;
}

.switch {
  margin-left: auto;
  margin-right: 20px;
}

/* Footer */

.modal-footer {
  padding: 12px 20px 16px;
}

.primary-btn {
  width: 100%;

  padding: 10px 14px;

  background: #4caf50;

  color: white;

  border: none;

  border-radius: 10px;

  font-size: 16px;

  cursor: pointer;
}

.primary-btn:hover {
  background: #43a047;
}

/* ---------- BOARD ---------- */

.board-wrapper {
  display: flex;

  justify-content: center;
}

.board {
  width: 100%;

  max-width: 420px;
}

.hint {
  font-size: 14px;
  margin-bottom: 12px;
}

.meaning {
  margin-bottom: 12px;
}

.grid {
  display: flex;

  justify-content: center;

  gap: 10px;

  margin: 20px 0;
}

/* ---------- TILE ---------- */

.box {
  width: 52px;

  height: 52px;

  border: 2px solid #ccc;

  border-radius: 8px;

  font-size: 24px;

  display: flex;

  align-items: center;

  justify-content: center;

  background: #fff;

  transform-style: preserve-3d;
}

.correct {
  background: #4caf50;

  color: #fff;

  border: none;
}

.wrong {
  background: #f44336;

  color: #fff;

  border: none;
}

/* ---------- ANIMATIONS ---------- */

@keyframes flip {
  0% {
    transform: rotateX(0);
  }

  50% {
    transform: rotateX(90deg);
  }

  100% {
    transform: rotateX(0);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

.flip {
  animation: flip 0.6s ease forwards;
}

.shake {
  animation: shake 0.4s ease;
}

/* ---------- INPUT ---------- */

textarea {
  width: 100%;

  font-size: 18px;

  padding: 10px;

  border-radius: 8px;

  border: 1px solid #ccc;
}

button {
  margin-top: 10px;

  padding: 12px 16px;

  font-size: 16px;

  cursor: pointer;

  border-radius: 8px;

  border: none;

  background: #000;

  color: #fff;
}

/* ---------- KEYBOARD ---------- */

.keyboard-wrapper {
  position: fixed;

  bottom: 0;

  left: 0;

  width: 100%;

  background: #eaecef;

  padding: 8px 6px 12px;

  z-index: 100;
}

.keyboard {
  max-width: 760px;

  margin: 0 auto;
}

.key-row {
  display: flex;

  justify-content: center;

  gap: 4px;

  margin-bottom: 6px;
}

.key {
  flex: 1 1 0;

  min-width: 0;

  padding: 10px 4px;

  background: #dfe3e8;

  border-radius: 6px;

  font-size: 16px;

  user-select: none;

  cursor: pointer;

  display: flex;

  align-items: center;

  justify-content: center;
}

.key.wide {
  flex: 2;
}

.key.action {
  background: #c7ccd1;
}

/* ---------- SHARE ---------- */

.message {
  margin-top: 12px;

  font-weight: bold;
}

.share {
  white-space: pre;

  margin-top: 10px;

  font-size: 14px;
}

.shareBtn {
  margin-top: 8px;

  display: none;

  background-color: #4caf50;

  color: white;
}

/** icons **/

.shareicon {
  font-weight: bold;

  position: relative;
}

.shareicon:before {
  content: ".";

  font-size: 2.2em;

  position: absolute;

  bottom: -2.5px;

  left: -4px;
}

.shareicon:after {
  content: ":";

  font-size: 2em;

  position: absolute;

  bottom: -6px;

  right: -6px;
}

/* ---------- VIEW RESULTS BUTTON ---------- */

.view-results-btn {
  display: none;
  margin: 0 auto 16px;
  padding: 10px 24px;
  background-color: var(--success-color, #6aaa64);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s, background-color 0.2s;
}

.view-results-btn:hover {
  background-color: #538d4e;
  transform: scale(1.02);
}

/* ---------- RESULT MODAL ---------- */

:root {
  --success-color: #6aaa64;
  --error-color: #e74c3c;
  --bg-color: #ffffff;
  --text-main: #1a1a1b;
  --text-secondary: #787c7e;
  --dark-green: #28672a;
}

/* The Modal Background */
.resultmodal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  /* When JS sets display:flex, these kick in for centering */
  align-items: center;
  justify-content: center;
}

#viewresultbar {
  margin-bottom: -3px;
  padding-right: 6px;
}

/* Modal Content Box */
.resultmodal-content {
  background-color: var(--bg-color);
  margin: auto;
  padding: 32px;
  border-radius: 16px;
  
  /* Responsive width */
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  position: relative;
  text-align: center;
  font-family: Tahoma, "Noto Sans Tamil", sans-serif;

  /* Entrance Animation */
  animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Close Button */
.resultmodalclose {
  position: absolute;
  right: 16px;
  top: 12px;
  color: var(--text-secondary);
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s;
}

.resultmodalclose:hover {
  color: var(--text-main);
}

/* Message Styling */
.message {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 20px;
  line-height: 1.4;
}

/* Styles for when game is won/lost (apply via JS) */
.msg-success {
  color: var(--success-color);
}

.msg-fail {
  color: var(--error-color);
}

/* The share-grid container */
.share-grid {
  font-size: 20px;
  letter-spacing: 2px;
  margin: 20px 0;
  line-height: 1.2;
}

/* Share Button */
.shareBtn {
  background-color: var(--success-color);
  color: white;
  border: none;
  padding: 12px 32px;
  font-size: 18px;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 auto;
  width: 100%;
  transition:
    transform 0.1s,
    background-color 0.2s;
}

.shareBtn:hover {
  background-color: #538d4e;
  transform: scale(1.02);
}

.shareBtn:active {
  transform: scale(0.98);
}

/* Popup Text */
/* Enhanced Popup styling */
.popuptext {
  visibility: hidden;
  opacity: 0;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 8px 12px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  /* Position above the button */
  left: 50%;
  transform: translateX(-50%);
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
  font-size: 14px;
  pointer-events: none;
  /* Prevents it from interfering with clicks */
}

/* The class we'll toggle with JS */
.popuptext.show {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
  /* Slight float up effect */
}

/** Popup **/

/* Popup container - can be anything you want */

.popup {
  position: relative;

  display: inline-block;

  cursor: pointer;

  -webkit-user-select: none;

  -moz-user-select: none;

  -ms-user-select: none;

  user-select: none;
}

/* The actual popup */

.popup .popuptext {
  visibility: hidden;

  width: 160px;

  background-color: #555;

  color: #fff;

  text-align: center;

  border-radius: 6px;

  padding: 8px 0;

  position: absolute;

  z-index: 1;

  bottom: 125%;

  left: 50%;

  margin-left: -80px;
}

/* Popup arrow */

.popup .popuptext::after {
  content: "";

  position: absolute;

  top: 100%;

  left: 50%;

  margin-left: -5px;

  border-width: 5px;

  border-style: solid;

  border-color: #555 transparent transparent transparent;
}

/* Toggle this class - hide and show the popup */

.popup .show {
  visibility: visible;

  -webkit-animation: fadeIn 1s;

  animation: fadeIn 1s;
}

/* Add animation (fade in the popup) */

@-webkit-keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ---------- MODE BUTTONS ---------- */

.mode-buttons {
  display: flex;

  gap: 10px;

  justify-content: center;

  margin: 10px;

  flex-wrap: wrap;
}

.mode-btn {
  border-radius: 8px;

  border: 2px solid #000;

  background: #fff;

  color: #000;

  cursor: pointer;

  font-weight: bold;

  transition: all 0.3s ease;
}

.mode-btn.active {
  background: #000;

  color: #fff;
}

.mode-btn:hover {
  transform: scale(1.05);
}

.toggle-tanglish-btn {
  font-size: 14px;

  background: white;

  border: none;

  border-radius: 6px;

  cursor: pointer;

  margin-top: 10px;

  display: none;
}

.toggle-tanglish-btn.visible {
  display: block;
}

/* ---------- RESPONSIVE ADJUSTMENTS ---------- */

/* Tablets/small laptops: slightly compact */

@media (max-width: 500px) {
  .keyboard-wrapper {
    padding: 8px 4px 10px;
  }

  .keyboard {
    padding: 0 4px;
  }

  .key {
    padding: 8px 3px;

    font-size: 14px;
  }

  .key-row {
    gap: 3px;

    margin-bottom: 4px;
  }
}

/* Mobile phones (e.g., Pixel 7): compress significantly */

@media (max-width: 420px) {
  body {
    padding-bottom: 320px;

    /* ensure space for 250px keyboard + margin */
  }

  .keyboard-wrapper {
    padding: 6px 3px 8px;

    height: 250px;

    /* fixed height for mobile */

    box-sizing: border-box;
  }

  .keyboard {
    padding: 0 2px;

    height: 100%;

    display: flex;

    flex-direction: column;

    justify-content: center;
  }

  .key-row {
    gap: 4px;

    margin-bottom: 6px;
  }

  .key {
    padding: 2px 2px;

    font-size: 13px;

    min-height: 52px;
  }

}

/* Mobile phones (e.g., Pixel 7): compress significantly */

@media (max-width: 390px) {
  body {
    padding-bottom: 320px;

    /* ensure space for 250px keyboard + margin */
  }

  .keyboard-wrapper {
    padding: 6px 3px 8px;

    height: 200px;

    /* fixed height for mobile */

    box-sizing: border-box;
  }

  .keyboard {
    padding: 0px;

    height: 100%;

    display: flex;

    flex-direction: column;

    justify-content: center;
  }

  .key-row {
    gap: 4px;

    margin-bottom: 6px;
  }

  .key {
    padding: 0px;

    font-size: 12px;

    min-height: 43px;
  }
}

/** Column **/

.row {
  display: flex;

  flex-direction: row;

  flex-wrap: wrap;

  width: 100%;
}

.column h4 {
  align-self: flex-start;

  color: gray;

  font-size: 14px;

  margin-left: 10px;
}

.column span {
  align-self: flex-end;

  font-size: 20px;

  padding-right: 10px;

  margin-right: 10px;
}

.column strong {
  font-size: 20px;
}

.column {
  display: flex;

  flex-direction: column;

  flex-basis: 100%;

  flex: 1;

  height: auto;

  background: #fff;

  color: #000;
}

/* ---------- TOGGLE SWITCH ---------- */

.switch {
  position: relative;

  display: inline-block;

  width: 50px;

  height: 24px;
}

.switch input {
  opacity: 0;

  width: 0;

  height: 0;
}

.slider {
  position: absolute;

  cursor: pointer;

  top: 0;

  left: 0;

  right: 0;

  bottom: 0;

  background-color: #ccc;

  transition: 0.4s;

  display: flex;

  align-items: center;

  justify-content: center;
}

.slider:before {
  position: absolute;

  content: "";

  height: 18px;

  width: 18px;

  left: 3px;

  bottom: 3px;

  background-color: white;

  transition: 0.4s;
}

input:checked+.slider {
  background-color: #2196f3;
}

input:checked+.slider:before {
  transform: translateX(26px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

.mode-label {
  margin-left: 8px;

  font-weight: bold;

  font-size: 16px;

  vertical-align: middle;
}

/* Label text inside slider */
.slider-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: bold;
  color: #000;
  pointer-events: none;
  user-select: none;
}

input:checked+.slider .slider-label {
  color: #fff;
}

/** GLITCH EFFECT **/

:root {
  --glow-color: black;
}

/* Flickering CRT Screen effect */

.screen-container {
  position: relative;

  animation: flicker 0.15s infinite;

  height: 40px;
}

.glitch-container {
  font-family: "Courier New", Courier, monospace;

  color: var(--glow-color);

  font-size: 2rem;

  font-weight: bold;

  letter-spacing: 8px;

  position: relative;

  text-transform: uppercase;
}

@keyframes flicker {
  0% {
    opacity: 0.97;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.98;
  }
}

/* Subtle distortion */

@keyframes jitter {
  0% {
    transform: skew(0deg);
  }

  10% {
    transform: skew(1deg);
  }

  20% {
    transform: skew(-1deg);
  }

  30% {
    transform: skew(0.5deg);
  }

  100% {
    transform: skew(0deg);
  }
}

.is-glitching {
  animation: jitter 0.1s infinite;
}

/* Disabled key style for vowel modifiers */
.key.disabled {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(100%);
}

/* ---------- GDPR CONSENT BANNER ---------- */
.gdpr-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1a1a2e;
  color: #eee;
  padding: 16px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.gdpr-content {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 800px;
  flex-wrap: wrap;
  justify-content: center;
}

.gdpr-content p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

.gdpr-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.gdpr-btn {
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.gdpr-btn:hover {
  transform: scale(1.05);
}

.gdpr-accept {
  background: #4caf50;
  color: #fff;
}

.gdpr-decline {
  background: transparent;
  color: #aaa;
  border: 1px solid #555;
}

.gdpr-decline:hover {
  color: #fff;
  border-color: #888;
}