
/* Kalam Regular */
@font-face {
  font-family: 'Kalam';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/kalam-v18-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Kalam';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/kalam-v18-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Kalam Bold */
@font-face {
  font-family: 'Kalam';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/kalam-v18-700-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Kalam';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/kalam-v18-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Patrick Hand */
@font-face {
  font-family: 'Patrick Hand';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/patrick-hand-v25-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Patrick Hand';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/patrick-hand-v25-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}


:root {
  --bg-color: #e0e5ec;
  --paper: #fdfdfd;
  --ink: #2c3e50;
  --accent: #3498db;
  --success: #27ae60;
  --error: #e74c3c;
  --tile-bg: #fff;
  --tile-shadow: rgba(0,0,0,0.1);
  --font-main: 'Patrick Hand', cursive;
  --font-sketch: 'Kalam', cursive;
}

body.theme2 {
  --bg-color: #0d1117;       
  --paper: #161b22;          
  --ink: #f0f6fc;            
  --accent: #f2994a;         
  --tile-bg: #21262d;        
  --tile-shadow: rgba(0,0,0,0.6);
}

* {
  box-sizing: border-box;
}

button, input, select, textarea {
  font-family: inherit;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(circle at 2px 2px, rgba(0,0,0,0.05) 1px, transparent 0);
  background-size: 30px 30px;
  color: var(--ink);
  display: flex;
  justify-content: center;
  align-items: flex-start; 
  padding: 5vh 0; 
  min-height: 100vh;
  margin: 0;
}

.logo {
  height: 50px; 
  max-width: 100%;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}



#hangman-img {
  max-width: 100%;
  max-height: 100%;
  filter: drop-shadow(0 10px 15px rgba(0,0,0,0.1));
}

.container {
  background-color: var(--paper);
  background-image: repeating-linear-gradient(rgba(0,0,0,0.02) 0px, rgba(0,0,0,0.02) 1px, transparent 1px, transparent 30px);
  border-radius: 30px;
  box-shadow: 20px 20px 60px rgba(0,0,0,0.05), -20px -20px 60px rgba(255,255,255,0.5);
  padding: 40px;
  position: relative;
  max-width: 1000px;
  width: 90%;
  border: 1px solid rgba(0,0,0,0.05);
  z-index: 1; 
}

body.theme2 .container {
    box-shadow: 0 20px 80px rgba(0,0,0,0.8);
    border-color: rgba(242, 153, 74, 0.1); 
}

header {
    margin-bottom: 80px;
    display: flex;
    justify-content: center;
    min-height: 50px; 
}

header img {
  width: 280px;
  max-width: 100%;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

header img:hover {
    transform: scale(1.05);
}


.top-bar {
  position: absolute;
  top: 25px;
  left: 30px;
  right: 30px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

.icon-btn {
  pointer-events: auto;
  background-color: transparent;
  border: 2px solid transparent;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--ink);
  opacity: 0.7;
}

.icon-btn:hover {
  color: var(--accent);
  opacity: 1;
}

.icon-btn:hover .icon {
  transform: scale(1.2);
}

.icon {
  width: 24px;
  height: 24px;
  background-color: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}


#theme-toggle {
  overflow: hidden;
  position: relative;
}

.theme-dial {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  
  transform: translate(0, 25px) rotate(0deg);
  transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

body.theme2 .theme-dial {
  transform: translate(0, 25px) rotate(180deg);
}

.sun-icon, .moon-icon {
  position: absolute;
  left: 0;
  width: 24px;
  height: 24px;
  
}

.sun-icon {
  
  top: -25px;
  transform: translate(-50%, -50%);
  mask-image: url('../images/ui/sun.svg');
  -webkit-mask-image: url('../images/ui/sun.svg');
}

.moon-icon {
  
  top: 25px;
  transform: translate(-50%, -50%) rotate(180deg);
  mask-image: url('../images/ui/moon.svg');
  -webkit-mask-image: url('../images/ui/moon.svg');
}


#theme-toggle:hover .sun-icon {
  transform: translate(-50%, -50%) scale(1.2);
}
#theme-toggle:hover .moon-icon {
  transform: translate(-50%, -50%) rotate(180deg) scale(1.2);
}

#mute-icon { mask-image: url('../images/ui/sounds.svg'); -webkit-mask-image: url('../images/ui/sounds.svg'); }
.is-muted #mute-icon { mask-image: url('../images/ui/mute.svg'); -webkit-mask-image: url('../images/ui/mute.svg'); }


.day-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.8s ease;
  background: 
    radial-gradient(circle at 15% 50%, rgba(255, 255, 255, 0.45) 0%, transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(255, 255, 255, 0.35) 0%, transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(255, 255, 255, 0.4) 0%, transparent 50%);
  animation: driftClouds 20s ease-in-out infinite alternate;
}

body.theme2 .day-bg {
  opacity: 0;
}

@keyframes driftClouds {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.05) translate(1%, 1%); }
}


.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.8s ease;
  background-image: 
    radial-gradient(1px 1px at 10% 20%, white, transparent),
    radial-gradient(1px 1px at 30% 60%, white, transparent),
    radial-gradient(2px 2px at 80% 40%, white, transparent),
    radial-gradient(1.5px 1.5px at 60% 80%, white, transparent),
    radial-gradient(2px 2px at 90% 90%, white, transparent),
    radial-gradient(1px 1px at 40% 10%, white, transparent),
    radial-gradient(1.5px 1.5px at 20% 80%, white, transparent),
    radial-gradient(1px 1px at 70% 20%, white, transparent);
  background-size: 300px 300px;
  animation: twinkle 15s linear infinite;
}

body.theme2 .stars {
  opacity: 0.4;
}

@keyframes twinkle {
  0% { transform: translateY(0); }
  100% { transform: translateY(-300px); }
}


::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  z-index: 1;
}

::view-transition-new(root) {
  z-index: 2; 
}



.game-main {
  display: flex;
  gap: 30px;
  align-items: stretch;
  justify-content: center;
  flex-wrap: wrap;
}

.visual-section {
  flex: 0.7; 
  min-width: 260px;
  border-radius: 25px;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.game-image {
  width: 100%;
  height: 320px;
  position: relative;
}

.game-image img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  object-fit: contain;
  
}

.game-image-bg {
  opacity: 0.08 !important;
  filter: grayscale(1) invert(0.2);
}

body.theme2 header img,
body.theme2 #hangman-img,
body.theme2 .game-image-bg {
  filter: invert(1) brightness(1.2) drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

body.theme2 .game-image-bg {
  opacity: 0.15 !important;
}

.control-section {
  flex: 2; 
  min-width: 500px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}


.category-display {
  text-align: center;
  font-size: 1.2em;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: bold;
  margin-bottom: 2px;
}

.category-label {
  color: var(--ink);
  opacity: 0.6;
}

.category-name {
  color: var(--accent);
}

.letter-space {
  width: 25px;
}


.game-word {
  display: flex;
  flex-wrap: wrap; 
  justify-content: center;
  padding: 30px 0;
  overflow: hidden;
  margin-bottom: 25px;
}

.letter-card {
  width: 44px; 
  height: 75px;
  perspective: 1000px;
  flex-shrink: 0;
}

.letter-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

.card-front, .card-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: contain; 
  background-repeat: no-repeat;
  background-position: center;
  transition: all 0.6s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}

.card-front {
  background-image: url('../images/ui/card_revers.svg');
  z-index: 2;
  transition: all 0.6s cubic-bezier(0.55, 0.055, 0.675, 0.19), filter 0.4s ease;
}

body.theme2 .card-front {
  filter: invert(0.9) brightness(0.9);
}

.card-back {
  background-image: none;
  color: var(--ink);
  font-family: var(--font-sketch);
  font-size: 50px; 
  font-weight: bold;
  line-height: 1;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 1;
}

.letter-card.revealed .card-front {
  transform: translateY(250px) rotate(30deg);
  opacity: 0;
  pointer-events: none;
}


.game-keyboard {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  padding: 5px;
  transition: opacity 0.2s ease;
}

.game-keyboard.cooldown {
  opacity: 0.6;
  pointer-events: none;
}

.game-keyboard button {
  font-family: var(--font-sketch);
  font-weight: 700;
  font-size: 1.4em;
  text-transform: uppercase;
  padding: 8px 0;
  border: none;
  background: var(--tile-bg);
  color: var(--ink);
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 0 var(--tile-shadow);
  transition: all 0.1s;
}

.game-keyboard button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--tile-shadow);
  background: var(--paper);
}

body.theme2 .game-keyboard button:hover:not(:disabled) {
  background: #2d333b;
}

.game-keyboard button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--tile-shadow);
}

.game-keyboard button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--tile-shadow);
}

.game-keyboard button.correct {
  background-color: var(--success);
  color: white;
  box-shadow: 0 4px 0 #1e6b3b;
}


@keyframes subtleShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-2px); }
  40%, 80% { transform: translateX(2px); }
}

.game-keyboard button.wrong {
  background-color: var(--error);
  color: white;
  animation: subtleShake 0.3s ease-in-out;
  box-shadow: 0 4px 0 #922b21;
}


.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  padding: 80px 100px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #333;
  position: relative;
  z-index: 1;
}

.modal-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../images/ui/popup.svg') no-repeat center;
  background-size: contain;
  z-index: -1;
  transition: filter 0.4s ease;
}

body.theme2 .modal-content {
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

body.theme2 .modal-content strong {
  color: var(--accent);
}

body.theme2 .modal-content::before {
  filter: invert(0.9) brightness(0.8) contrast(1.1);
}

.modal-content h2 {
  font-size: 2.5em;
  margin: 0 0 10px 0;
  font-family: inherit;
}

.modal-content p {
  font-size: 1.4em;
  margin: 0 0 20px 0;
}

.modal-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  margin-bottom: 20px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

}

.stat-label {
  font-size: 1.6em;
  opacity: 0.8;
}

.stat-value {
  font-size: 3em;
  color: var(--accent);
}

.main-stat .stat-value {
  font-size: 2.8em;
  color: var(--error);
  font-family: var(--font-sketch);
}

.stats-grid {
  display: flex;
  justify-content: center;
  gap: 30px;
  border-top: 2px dashed rgba(0,0,0,0.1);
  padding-top: 15px;
      max-width: 70%;
}

body.theme2 .stats-grid {
  border-top-color: rgba(255,255,255,0.1);
}

.lose-msg {
  font-size: 1.5em !important;
  color: var(--error);
  font-weight: bold;
}

.play-again-btn {
  background: url('../images/ui/play_btn.svg') no-repeat center;
  background-size: contain;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  font-size: 0; 
  transition: transform 0.2s ease, filter 0.4s ease;
}

body.theme2 .play-again-btn {
  filter: invert(1);
}

.play-again-btn:hover {
  transform: scale(1.1);
  background-color: transparent;
}

@media (max-width: 768px) {
  body {
    align-items: flex-start;
    padding: 0;
  }

  .container {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    border-radius: 0;
    padding: 15px;
    box-shadow: none;
    display: flex;
    flex-direction: column;
  }

  header {
    margin-bottom: 0;
    width: 100%;
  }

 

  .game-main {
    flex-direction: column;
    gap: 0;
    flex: 1; 
    display: flex;
  }

  .visual-section {
    width: 100%;
    min-width: unset;
    flex: 0 0 auto;
    margin-bottom: 15px; 
  }

  .game-image {
    height: 170px; 
  }

  .control-section {
    width: 100%;
    min-width: unset;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between; 
  }

  .category-display {
    font-size: 0.9em;
    margin-bottom: 0;
  }

  .game-word {
    margin: 10px 0 30px 0; 
    flex-wrap: wrap; 
    justify-content: center;
    flex: 0 0 auto;
    gap: 3px;
    padding: 10px 0;
  }

  .letter-space {
    width: 15px;
  }

  .letter-card {
    width: min(22px, 6.5vw);   
    height: 35px;  
    flex-shrink: 1; 
  }

  .card-front {
    background-position: bottom;
    background-size: contain;
    transition: all 0.5s ease-out;
  }

  .letter-card:nth-child(even) .card-front {
    background-image: url('../images/ui/underscore_even.svg');
  }

  .letter-card:nth-child(odd) .card-front {
    background-image: url('../images/ui/underscore_odd.svg');
  }

  .card-back {
    font-size: min(30px, 7vw);
    font-weight: bold;
  }

  .game-keyboard {
    gap: 4px;
    row-gap: 8px;
    padding: 5px 0 10px 0;
  }

  .game-keyboard button {
    font-size: 1.0em;
    padding: 4px 0;
    border-radius: 8px;
  }

  .top-bar {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    margin-bottom: 25px;
    align-items: center;
  }

  
  .modal-content {
    width: 90vw;
    padding: 60px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .modal-content::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    
    width: 70vh;  
    height: 90vw; 
    max-width: 550px;
    max-height: 400px;
    transform: translate(-50%, -50%) rotate(90deg);
    background: url('../images/ui/popup.svg') no-repeat center !important;
    background-size: 100% 100% !important;
    z-index: -1;
  }

  .modal-content h2 {
    font-size: 2.4em;
    margin-bottom: 20px;
    line-height: 1;
  }

  .modal-content p {
    font-size: 1.4em;
    margin-bottom: 15px;
  }

  .modal-stats {
    gap: 10px;
    margin-bottom: 10px;
  }

  .stats-grid {
    flex-direction: column;
    gap: 5px;
    border-top-width: 1px;
    padding-top: 10px;
  }

  .stat-item {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
    align-items: baseline;
  }

  .main-stat {
    align-items: center;
    flex-direction: column;
    margin-bottom: 5px;
  }

  .stat-label {
    font-size: 1em;
  }

  .stat-value {
    font-size: 1.4em;
  }

  .main-stat .stat-value {
    font-size: 2.2em;
  }

  .play-again-btn {
    width: 60px;
    height: 60px;
    margin-top: 20px;
  }
}
