* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Google Sans Code", monospace;
}

body {
    background-color: #1a1a1a;
    color: #ffffff;
    overflow: hidden;
    height: 100vh;
}

.head-container {
    position: fixed;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    top: 10px;
    left: 10px;
    z-index: 9000;
    width: 0;
}

.header {
    background-color: #2d2d2d66;
    border: 1px solid #444;
    border-radius: 4px;
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    color: #ccc;
    display: block;
    width: max-content;
}

.header h1 {
    font-size: 1.25rem;
}

.header a {
    color: #007acc;
    text-decoration: none;
    font-size: 0.66rem;
}

.header a:hover {
    text-decoration: underline;
    color:#0099ff;
}

/* ツールバー */
.toolbar {
    background-color: #2d2d2d66;
    border: 1px solid #444;
    border-radius: 4px;
    backdrop-filter: blur(10px);
    padding: 20px;
    overflow-y: auto;
    display: block;
    width: max-content;
}

.toolbar-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #ccc;
    pointer-events: none;
    user-select: none;
    display: flex;
    justify-content: center;
}

.toolbar-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #444;
}

.toolbar-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.tool-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.tool-btn {
    width: 40px;
    height: 40px;
    background-color: #404040;
    border: 2px solid #555;
    color: #fff;
    cursor: pointer;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background-color: #505050;
    border-color: #666;
}

.tool-btn.active {
    background-color: #007acc;
    border-color: #0099ff;
}

.edit-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.edit-btn {
    width: 40px;
    height: 40px;
    background-color: #404040;
    border: 2px solid #555;
    color: #fff;
    cursor: pointer;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.edit-btn:hover {
    background-color: #505050;
    border-color: #666;
}


/* キャンバス */
.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    background-color: #0a0a0a;
    z-index: 1;
}

.canvas {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: auto;
    cursor: crosshair;
}

.ascii-content {
    position: relative;
    min-width: 2000px;
    min-height: 2000px;
    font-size: 14px;
    line-height: 14px;
    letter-spacing: 0px;
    white-space: pre;
    color: #00ff00;
    user-select: none;
    transform-origin: 0 0;
    background-image:
        linear-gradient(rgba(128, 128, 128, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(128, 128, 128, 0.2) 1px, transparent 1px);
    background-size: 8px 14px; /* 文字幅と文字高さに合わせる */
    background-position: 0 0, 0 0;
}

/* ASCII要素スタイル */
.ascii-element {
    position: absolute;
    cursor: default;
    user-select: none;
    white-space: pre;
    color: #FFFFFF; /* 非選択時は白 */
    transition: color 0.2s ease;
}

.ascii-element.selected {
    color: #00ff00; /* 選択時は緑 */
    z-index: 2000 !important;
}

.ascii-element.rectangle.selected,
.ascii-element.text.selected {
    background-color: rgba(45, 45, 45, 0.2);
    backdrop-filter: blur(4px);
}

.ascii-element.rectangle,
.ascii-element.line {
    cursor: move;
}

.ascii-element.text {
    cursor: move;
}

.ascii-element.text.editing {
    background-color: rgba(0, 122, 204, 0.2);
    border: 1px dashed #007acc;
    padding: 2px;
}

/* 選択ハンドル */
.resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #007acc;
    border: 1px solid #ffffff;
    cursor: nwse-resize;
    z-index: 5000;
}

.resize-handle.nw { cursor: nw-resize; }
.resize-handle.ne { cursor: ne-resize; }
.resize-handle.sw { cursor: sw-resize; }
.resize-handle.se { cursor: se-resize; }
.resize-handle.n { cursor: n-resize; }
.resize-handle.s { cursor: s-resize; }
.resize-handle.w { cursor: w-resize; }
.resize-handle.e { cursor: e-resize; }
.resize-handle.start { cursor: move; }
.resize-handle.end { cursor: move; }

/* 座標表示 */
.coordinates {
    position: absolute;
    bottom: 10px;
    right: 10px;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 12px;
    color: #ccc;
    pointer-events: none;
    background-color: #2d2d2d66;
    border: 1px solid #444;
    border-radius: 4px;
    backdrop-filter: blur(10px);
    z-index: 9000;
}

/* ドラッグ中のプレビュー */
.drag-preview {
    position: absolute;
    pointer-events: none;
    border: 1px dashed #007acc;
    background-color: rgba(0, 122, 204, 0.1);
}

/* テキスト入力フィールド */
.text-input-field {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    border: 1px solid #007acc;
    color: #ffffff;
    font-size: 14px;
    padding: 2px;
    outline: none;
    z-index: 8000;
}

/* スクロールバーのスタイル */
.canvas::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.canvas::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.canvas::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 6px;
}

.canvas::-webkit-scrollbar-thumb:hover {
    background: #505050;
}

/* 選択ツール時のカーソル */
.canvas.select-mode {
    cursor: default;
}

.canvas.select-mode .ascii-char:hover {
    background-color: rgba(0, 122, 204, 0.2);
}

.canvas.select-mode .ascii-text:hover {
    background-color: rgba(0, 122, 204, 0.2);
}

/* 矩形ツール時のカーソル */
.canvas.rectangle-mode {
    cursor: crosshair;
}

/* 直線ツール時のカーソル */
.canvas.line-mode {
    cursor: crosshair;
}

/* テキストツール時のカーソル */
.canvas.text-mode {
    cursor: text;
}

.copyright {
    position: fixed;
    bottom: 10px;
    left: 10px;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 12px;
    color: #ccc;
    pointer-events: none;
    z-index: 9000;
    background-color: #2d2d2d66;
    border: 1px solid #444;
    border-radius: 4px;
    backdrop-filter: blur(10px);
}

/* ローディングスピナー */
.loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: #ffffff;
    font-family: "Google Sans Code", monospace;
    font-size: 14px;
}

.loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top: 3px solid #007acc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    background-color: rgba(45, 45, 45, 0.9);
    padding: 10px 20px;
    border-radius: 4px;
    border: 1px solid #444;
    backdrop-filter: blur(10px);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}