html {
	background: #323437;
	transition: 1s ease;
	font-family: sans-serif;
	word-break: break-all;
	text-align: center;
    overflow-y: hidden;
}

header {
	position: relative;
	z-index: 10;
	width: auto;
	height: 70px;
	line-height: 70px;
	max-width: 800px;
	margin: 0 auto;
	background: #323437;
    transition: opacity 0.4s ease-out;
}

.header-hidden {
    opacity: 0;
    pointer-events: none;
}

.header-left {
	float: left;
}

.header-left h1 {
	text-align: left;
	margin: 0;
	color: white;
}

.header-right {
	text-align: right;;
}

.header-right .icon {
	margin-left: 20px;
	padding: 0;
}

.fa-computer-mouse {
	font-size: 1.2em;
}

.icon-logo {
	font-size: 1.5em;
	color: white;
}

.header-right button {
	background-color: transparent;
	border: none;
	margin: 0;
}

input[type="range"] {
  -webkit-appearance: none; /* 🚩これ無しだとスタイルがほぼ全く反映されないので注意 */
  appearance: none;
  cursor: pointer; /* カーソルを分かりやすく */
  outline: none; /* スライダーのアウトラインは見た目がキツイので消す */
  height: 6px; /* バーの高さ */
  width: 10%; /* バーの幅 */
  background: #8acdff; /* バーの背景色 */
  border-radius: 10px; /* バーの両端の丸み */
  border: solid 3px #dff1ff; /* バー周囲の線 */
}
/* WebKit向けのつまみ */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; /*  🚩デフォルトのつまみのスタイルを解除 */
  background: #53aeff; /* 背景色 */
  width: 20px; /* 幅 */
  height: 20px; /* 高さ */
  border-radius: 50%; /* 円形に */
  box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.15); /* 影 */
}
/* Moz向けのつまみ */
input[type="range"]::-moz-range-thumb {
  background: #53aeff; /* 背景色 */
  width: 20px; /* 幅 */
  height: 20px; /* 高さ */
  border-radius: 50%; /* 円形に */
  box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.15); /* 影 */
  border: none; /* デフォルトの線を消す */
}
/* Firefoxで点線が周りに表示されてしまう問題の解消 */
input[type="range"]::-moz-focus-outer {
  border: 0;
}
/* つまみをドラッグしているときのスタイル */
input[type="range"]:active::-webkit-slider-thumb {
  box-shadow: 0px 5px 10px -2px rgba(0, 0, 0, 0.3);
}



#textJapanese {
	font-size: 40px;
	color: white;
	margin: 20px 0;
}

#textHurigana{
	font-size: 18px;
	color: #646669;
}

#morseJapanese{
	color : #646669;
}

.text span {
	border-right: 2px solid #e2b714;
}

.conversion-wrapper li {
	list-style: none;
	padding: 2px 10px;
	text-align: left;
    color: white;
    font-size: 14px;
}

/* 縦並び２列 */
.list {
  display: inline-grid;
  column-gap: 2em;
  grid-auto-flow: column;
  grid-template-rows: repeat(10, auto);
}

.color-white { color: white; }
.color-gray { color: #646669; }

/* --- ページ切り替えトランジション設定 --- */

/* 2つの画面を重ねるための設定 */
main {
    position: relative;
}

/* 切り替え対象の要素に共通で適用するスタイル */
.page-content {
    /* position:absoluteで同じ位置に要素を重ねる */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;

    /* opacity（透明度）の変化に0.4秒かける */
    transition: opacity 0.4s ease-out;
}

/* 非表示状態を管理するクラス */
.is-hidden {
    /* 透明にする */
    opacity: 0;
    /* 透明な状態でもクリックなどが効かないようにする */
    pointer-events: none;
}

.is-invisible {
    display: none;
}

/* --- AIチャットページのスタイル --- */
#aiChatToggleElement {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.APIgetform {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 20px;
}

.getApi {
    width: 80%;
    max-width: 500px;
    padding: 12px;
    margin-right: 8px;
    background-color: #25272a;
    border: 1px solid #555;
    border-radius: 5px;
    color: #ffffff;
    font-size: 1em;
    text-align: left;
}

.getApi::placeholder {
    color: #888;
}

.APIgetform button {
    padding: 12px 20px;
    background-color: #53aeff;
    border: 1px solid #53aeff;
    border-radius: 5px;
    color: white;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.APIgetform button:hover {
    background-color: #8acdff;
    border-color: #8acdff;
}

.talk-wrapper {
    height: 350px;
    width: 90%;
    background-color: #25272a;
    border: 1px solid #555;
    border-radius: 5px;
    color: #ffffff;
    font-size: 1em;
    text-align: left;
    padding: 10px;
    margin-bottom: 20px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Space between messages */
    padding: 10px; /* Changed from 10px 0 */
    height: 330px; /* Give it a height within the wrapper */
    overflow-y: auto;
}

/* Common style for all message bubbles */
.chat-container > div {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 15px;
    word-wrap: break-word; /* Break long words */
    line-height: 1.4;
}

/* User message bubble */
.user {
    background-color: #53aeff; /* Blue, consistent with the button */
    color: white;
    border-radius: 15px 15px 0 15px; /* "Tail" effect */
    align-self: flex-end; /* Align to the right */
}

/* Model message bubble */
.model {
    background-color: #404245; /* A darker gray */
    color: white;
    border-radius: 15px 15px 15px 0; /* "Tail" effect on the other side */
    align-self: flex-start; /* Align to the left */
}

/* System message style */
.system {
    background-color: #ff5c5c; /* Red for errors */
    color: white;
    align-self: center;
    text-align: center;
    border-radius: 5px;
}

.system-success {
    background-color: #4CAF50; /* Green for success */
    color: white;
    align-self: center;
    text-align: center;
    border-radius: 5px;
    max-width: 70%; /* Inherit from chat bubbles for consistency */
    padding: 10px 15px;
    word-wrap: break-word;
    line-height: 1.4;
}

.system-info {
    background-color: #6c757d; /* Neutral gray for info */
    color: white;
    align-self: center;
    text-align: center;
    border-radius: 5px;
    max-width: 70%;
    padding: 10px 15px;
    word-wrap: break-word;
    line-height: 1.4;
}

/* Webkit Scrollbar Styling */
.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: #25272a;
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 4px;
    border: 2px solid #25272a;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background-color: #777;
}

#input-container {
    display: flex;
    align-items: center;
    width: 90%;
    gap: 10px;
    margin-bottom: 20px;
}

.user-input-area {
    flex-grow: 1;
    display: flex;
    background-color: #25272a;
    border: 1px solid #555;
    border-radius: 5px;
    padding: 10px;
    color: white;
    text-align: left;
}

#aitext, #chat-text {
    margin: 0;
}

.morse-button {
    padding: 12px 20px;
    background-color: #53aeff;
    border: 1px solid #53aeff;
    border-radius: 5px;
    color: white;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.morse-button:hover {
    background-color: #8acdff;
    border-color: #8acdff;
}

.user {
    color: black;
    text-align: right;
    background-color: #dcf8c6;
}

.model .toggle-button {
    background-color: transparent;
    border: none;
    color: white;
    cursor: pointer;
    margin-right: 8px;
    font-size: 1.2em;
}

.model .play-sound-button {
    background-color: transparent;
    border: none;
    color: white;
    cursor: pointer;
    margin-right: 8px;
    font-size: 1.2em;
}

.model .play-sound-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* --- Settings Screen --- */
.settings-screen {
    position: fixed;
    top: 0;
    right: -350px; /* Start off-screen */
    width: 350px;
    height: 100%;
    background-color: #25272a;
    border-left: 1px solid #555;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2);
    transition: right 0.3s ease-in-out;
    z-index: 1000;
    color: white;
}

.settings-screen.is-active {
    right: 0; /* Slide in */
}

.settings-container {
    padding: 20px;
}

.settings-container h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 30px;
    color: #ffffff;
    border-bottom: 1px solid #555;
    padding-bottom: 10px;
}

/* --- Overlay --- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999; /* Below settings screen (1000) but above everything else */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

.overlay.is-active {
    opacity: 1;
    pointer-events: auto; /* Allow clicks on the overlay (to close the menu) */
}

/* --- Settings Items --- */
.setting-item {
    margin-bottom: 25px;
}

.setting-item h3 {
    text-align: left;
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #ddd;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
}

.setting-item h3 .fa-solid {
    margin-right: 10px;
    color: #888;
}

.volume-control {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Overwrite range input style for settings screen */
.settings-screen input[type="range"] {
    width: 100%; /* Make slider wider inside settings */
}

#morseListButton {
    padding: 12px 20px;
    background-color: #555;
    border: 1px solid #555;
    border-radius: 5px;
    color: white;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#morseListButton:hover {
    background-color: #777;
    border-color: #777;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: #ffffff;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
	transition: opacity 0.3s ease;
}

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

.modal-content {
    background-color: #25272a;
    padding: 20px;
    border-radius: 5px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
	transform: scale(0.9);
    opacity: 0;
    transition: all 0.3s ease;
}

.modal:not(.is-hidden) .modal-content {
    transform: scale(1);
    opacity: 1;
}

.modal-content h2 {
    color: white;
    text-align: center;
    margin-bottom: 20px;
}

.close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

#morse-table-container {
    color: white;
    padding: 0 20px;
}

.morse-table-columns {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2em;
}

.morse-table-columns ul {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    font-size: 0.9em;
}

.morse-table-columns li {
    padding: 2px 10px;
}

/* Toggle Switch Styles */
.toggle-switch-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .4s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #53aeff;
}

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

.morse-wrapper {
    position: relative;
}

.listening-practice-container {
    position: relative;
}

#listeningPracticeButton {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: transparent;
    border: none;
    padding: 0;
    font-size: 1.2em;
}

#backToPracticeButton {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: transparent;
    border: none;
    padding: 0;
    font-size: 1.2em;
}

/* --- Listening Practice UI --- */
.questions-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 1000px;
    margin: 20px auto;
    padding: 10px;
    box-sizing: border-box;
}

#question-listen {
    grid-column: 1 / -1; /* Span across both columns */
    justify-self: center;
    background-color: #404245;
    border: none;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 1.5em;
    cursor: pointer;
    margin-bottom: 15px;
    transition: background-color 0.3s ease;
}

#question-listen:hover {
    background-color: #555;
}

.choice {
    background-color: #25272a;
    border: 1px solid #555;
    color: white;
    padding: 25px;
    font-size: 1.1em;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.choice:hover {
    background-color: #404245;
    border-color: #888;
}

.feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 5em;
    color: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    z-index: 2000;
}

.feedback-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.feedback-overlay.correct {
    color: #4CAF50;
}

.feedback-overlay.incorrect {
    color: #F44336;
}

@keyframes fade-in-out {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

.feedback-overlay.animate {
    animation: fade-in-out 1s ease-in-out;
}

/* --- Start Screen --- */
.start-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin-top: -70px; /* Pull container up to compensate for invisible header */
    color: white;
}

#start-screen .start-container {
    padding-bottom: 10vh; /* Push content up from the center */
}

.start-container h2 {
    font-size: 3em;
    margin-bottom: 10px;
}

.start-container p {
    font-size: 1.2em;
    margin-bottom: 40px;
    color: #aaa;
}

.start-buttons {
    display: flex;
    gap: 20px;
}

.start-btn {
    padding: 15px 30px;
    font-size: 1.2em;
    color: white;
    background-color: #53aeff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.start-btn:hover {
    background-color: #8acdff;
}

.back-button {
    margin-top: 40px;
    background: none;
    border: 1px solid #555;
    color: #aaa;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-button:hover {
    background: #555;
    color: white;
}

.back-button-ingame {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: transparent;
    border: none;
    padding: 0;
    font-size: 1.2em;
    cursor: pointer;
    z-index: 20; /* Ensure it's above other elements */
}

/* --- Mode Switch --- */
.mode-switch {
    display: flex;
    border: 1px solid #53aeff;
    border-radius: 5px;
    overflow: hidden;
}

.mode-radio {
    display: none; /* Hide the actual radio button */
}

.mode-label {
    padding: 15px 30px;
    font-size: 1.2em;
    color: #53aeff;
    background-color: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

/* Add a separator line */
.mode-label:not(:last-of-type) {
    border-right: 1px solid #53aeff;
}

.mode-radio:checked + .mode-label {
    background-color: #53aeff;
    color: white;
}

.mode-label:hover {
    background-color: #404245;
}

.mode-radio:checked + .mode-label:hover {
    background-color: #8acdff; /* Lighter blue on hover when selected */
}

/* --- Game Stats --- */
#game-stats {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 15px;
    color: white;
    font-size: 1em;
    padding: 8px 12px; /* Adjusted padding */
    background-color: #25272a;
    border-radius: 5px;
}

.game-stat-item {
    display: flex;
    gap: 8px; /* Space between label and value */
}

/* --- Result Modal --- */
.result-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

/* --- Result Modal Enhancements --- */
.result-modal-content {
    background: linear-gradient(145deg, #2a2d30, #3a3e42);
    border-radius: 15px;
    padding: 30px 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    text-align: center;
}

.result-title {
    font-size: 2.5em;
    color: #53aeff;
    margin-bottom: 20px;
    font-weight: bold;
}

.final-score-container {
    margin-bottom: 30px;
}

.final-score-label {
    font-size: 1.2em;
    color: #aaa;
    margin-bottom: 5px;
}

.final-score-value {
    font-size: 4em;
    color: #ffffff;
    font-weight: bold;
    margin: 0;
    line-height: 1;
}

.result-stats {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: #25272a;
    padding: 20px;
    border-radius: 10px;
    flex-grow: 1;
    border: 1px solid #444;
}

.stat-card .fa-solid {
    font-size: 2em;
    color: #53aeff;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 1em;
    color: #aaa;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.8em;
    color: #ffffff;
    font-weight: bold;
    margin: 0;
}

/* --- Mode Selection Options --- */
.mode-option-item {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 25px;
    gap: 15px;
    transition: opacity 0.3s ease;
}

.mode-option-label {
    font-size: 1.2em;
    color: #ddd;
}

.mode-option-item.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* --- Start Screen Menu --- */
#start-menu-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
}

#start-menu-container .icon {
    background-color: transparent;
    border: none;
    padding: 0;
    font-size: 1.5em;
}

#start-menu-panel {
    position: absolute;
    top: 50px;
    right: 0;
    background-color: #25272a;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 10px 0;
    width: 180px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

#start-menu-panel.is-hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

#start-menu-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#start-menu-panel li a {
    display: block;
    padding: 12px 20px;
    color: #ddd;
    text-decoration: none;
    text-align: left;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#start-menu-panel li a:hover {
    background-color: #53aeff;
    color: white;
}

/* AI Chat Slide-up Panel */
.slide-up-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40vh;
    background-color: #333;
    color: white;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
    z-index: 10;
    /* Add visibility hidden to prevent interaction when off-screen */
    visibility: hidden;
}

.slide-up-panel.is-visible {
    transform: translateY(0);
    visibility: visible;
}